Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
988 views
in Technique[技术] by (71.8m points)

powershell - Avoiding newline in write-output

I want to collect all output from my script in a log file and must use write-output instaed of write-host.

Write-Output "Server:" $a looks like

Server:
foo
.

Do I really have to write to write
write-output $("sfdghk:" + $a) to get Server:Foo

Thanks -jt

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Found somewhere on the Internet:

Write-Output "Server: $($a)"

Works great in my code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...