【发布时间】:2018-11-02 14:32:01
【问题描述】:
我有一个在 Powershell 中运行的脚本,我希望能够在我的结果文本文件输出中的 ccript 名称和脚本内容本身之间放置一行。
目前,从下面,$str_msg = $file,[System.IO.File]::ReadAllText($file.FullName) 行是我需要的,但我需要一行来分隔$file 和下一个表达式的结果。我该怎么做?
foreach ($file in [System.IO.Directory]::GetFiles($sqldir,"*.sql",
[System.IO.SearchOption]::AllDirectories))
{
$file = [System.IO.FileInfo]::new($file);
$Log.SetLogDir("");
$str_msg = $file,[System.IO.File]::ReadAllText($file.FullName);
$Log.AddMsg($str_msg);
Write-Output $str_msg;
# ...
}
【问题讨论】:
标签: powershell newline string-interpolation