How do I output text without a newline in PowerShell?

前端 未结 17 2331
独厮守ぢ
独厮守ぢ 2020-12-07 15:13

I want my PowerShell script to print something like this:

Enabling feature XYZ......Done

The script looks something like this:



        
17条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 15:52

    Yes, as other answers have states, it cannot be done with Write-Output. Where PowerShell fails, turn to .NET, there are even a couple of .NET answers here but they are more complex than they need to be.

    Just use:

    [Console]::Write("Enabling feature XYZ.......")
    Enable-SPFeature...
    Write-Output "Done"
    

    It is not purest PowerShell, but it works.

提交回复
热议问题