代码 -
Write-Output "No. Excluded files:" $Global:exclusioncount | Out-File DryRun.txt -append
然而,变量在不同的行上输出。无论如何都要在同一条线上输出它?
答案 0 :(得分:4)
以下三种方法可以解决这个问题:
Write-Output ("No. Excluded files:{0}" -f $Global:exclusioncount) | Out-File DryRun.txt -append
Write-Output "No. Excluded files:$($Global:exclusioncount)" | Out-File DryRun.txt -append
Write-Output ("No. Excluded files:" + $Global:exclusioncount) | Out-File DryRun.txt -append