首页 > 解决方案 > 使用 powershell 5.1 忽略 write-host -NoNewline 参数

问题描述

从 WMF 5.1 开始,该-NoNewLine选项Write-Host基本上被忽略了。

简单的例子:

PS C:\> Write-Host "no newline test " -NoNewline

当前行为:

no newline test

PS C:\>

预期行为

no newline test PS C:\>

PS版表如下:

Name Value 
---- ----- 
PSVersion 5.1.14409.1012 

PSEdition Desktop 

PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} 

BuildVersion 10.0.14409.1012 

CLRVersion 4.0.30319.42000 

WSManStackVersion 3.0 

PSRemotingProtocolVersion 2.3 

SerializationVersion 1.1.0.1

根据 Microsoft docs for powershell 5.1,Next Prompt 应该在Write-Host "no newline test" -NoNewline语句输出之后出现在同一行中。

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-host?view=powershell-5.1

知道为什么它没有按预期运行吗?

标签: powershellpowershell-5.0

解决方案


推荐阅读