Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Write-Host - unwanted spaces appearing

$
0
0

Trying my best to ditch .bat's and adopt  .ps1's!

This is simplified code that shows what is happening.

I have a PowerShell function which returns some text:

function test { return 'StartOfLine' }

I then call the function with a write-host command:

Write-Host $(test)EndOfLine

What I would expect (and want) is this:

StartOfLineEndOfLine

What I get is this:

StartOfLine EndOfLine

Is there a way of removing the 'extra' space?

I can use this, but it's not neat:

Write-Host $(test) -NoNewline

Write-Host 'EndOfLine'

Any help would be most appreciated.


Viewing all articles
Browse latest Browse all 6937

Trending Articles