Quantcast
Channel: SAPIEN Forums
Viewing all articles
Browse latest Browse all 427

PowerShell Studio • Write-Host $null -NoNewline Writes a Space

$
0
0
Product: PowerShell Studio 2024 (64 Bit)
Build: v5.8.238
OS: Windows 10.0.19045
PS Version(s): 5.1.19041.1, 7.4.1

A small, but annoying event occurs when executing the following code:

Code:

Write-Host "===="
Write-Host $null -NoNewline; Write-Host "Test"
Write-Host "===="
or

Code:

Write-Host "===="
Write-Host "" -NoNewline; Write-Host "Test"
Write-Host "===="
The output produced shows, what appears to be a space character, has been written to screen which pushes "Test" along by 1 character.
==== Test====
When executed directly under PowerShell 5.1 ISE or 7.4 command line, the output correctly displays without the space being generated.

Thanks
G

Statistics: Posted by gareth.jacobs — Thu Apr 04, 2024 7:25 pm



Viewing all articles
Browse latest Browse all 427

Trending Articles