Concatenation Variables Problem with extra space

The problem is I want to concatenate two variables, however I cant get rid of a space between the two.

e.g. 1 Write-Host $_.ServerName $blah.ShareName

output \Server\ Share

I have tried some variations but all fail badly!

That’s because you’re using Write-Host and passing it two parameters.


You should look into Join-Path, though. It’s specifically designed for joining path components.