我制作了一个简单的 PowerShell 消息框来显示丢失文件的名称。我用变量调用它们。当我在 ISE 中回显变量时,它会在单独的行中显示每个变量,但是当显示在消息框中时,它会显示为由空格分隔的字符串。我没有运气用 `n 替换空格,但也许我做错了。
有人有想法么?
当前代码:
$missing = Compare-Object $capture.BaseName $output.BaseName | Select-Object -ExpandProperty InputObject
If($missing -ne $null){
Write-Host 'Here are the missing file(s):'
echo $missing
#send pop up alert
$ButtonType = [System.Windows.MessageBoxButton]::OK
$MessageboxTitle = “Please Process Files”
$Messageboxbody = “
The following are missing:
$missing”
$MessageIcon = [System.Windows.MessageBoxImage]::Warning
[System.Windows.MessageBox]::Show($Messageboxbody,$MessageboxTitle,$ButtonType,$messageicon)
}Else{
}
ISE 中的输出如下所示:
文件 1
文件2
文件 3
消息框中的输出如下所示:
文件 1 文件 2 文件 3