且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在PowerShell字符串中保留换行符

更新时间:2023-11-13 22:03:04

这可能会有所帮助:

$msg = "Output of other.exe: " + "`r`n" + ( (.\other.exe) -join "`r`n")

您从other.exe获取行列表,而不是文本

You get a list of lines and not a text from other.exe

$a = ('abc', 'efg')
 "Output of other.exe: " + $a


 $a = ('abc', 'efg')
 "Output of other.exe: " +  "`r`n" + ($a -join "`r`n")