【发布时间】:2010-12-13 17:38:56
【问题描述】:
在 PowerShell 脚本中,我在变量中捕获 EXE 文件的字符串输出,然后将其与其他一些文本连接起来以构建电子邮件正文。
但是,当我这样做时,我发现输出中的换行符减少为空格,使总输出不可读。
# Works fine
.\other.exe
# Works fine
echo .\other.exe
# Works fine
$msg = other.exe
echo $msg
# Doesn't work -- newlines replaced with spaces
$msg = "Output of other.exe: " + (.\other.exe)
为什么会发生这种情况,我该如何解决?
【问题讨论】:
标签: string powershell newline