Messagebox中的Powershell脚本LineFeed

时间:2019-01-31 12:54:53

标签: powershell linefeed tpm

我需要帮助在消息框中将卷$_.mountpoint之后的输出排序。

if ((Get-Tpm).TPMReady -eq $true){
    $tpminfo = Get-WmiObject -class Win32_Tpm -namespace root\CIMV2\Security\MicrosoftTpm
    [string]$tpmversion = $tpminfo.PhysicalPresenceVersionInfo 
    [System.Windows.MessageBox]::Show( "TPM Enabled "+$lf+ $lf + "VOLUMES: $lf"+ `
    (Get-BitLockerVolume |select-object mountpoint,VolumeStatus| `
    ForEach-Object {$lf,$_.MountPoint, $_.VolumeStatus}))

} else {
    [System.Windows.MessageBox]::Show( "TPM DISABLED "+$lf+ $lf + "VOLUMES: $lf"+ `
    (Get-BitLockerVolume |select-object mountpoint,VolumeStatus| `
    ForEach-Object {$lf,$_.MountPoint, $_.VolumeStatus}))

    EXIT
}

感谢Mattias

1 个答案:

答案 0 :(得分:0)

尝试使用插入换行的这种方式来代替:

[System.Windows.MessageBox]::Show( "TPM Enabled: $thing`r`nVolumes:$thing")

因此,在您的脚本中,我会这样做(未经测试):

[System.Windows.MessageBox]::Show( "TPM DISABLED`r`n`r`nVOLUMES: `r`n" +`
    (Get-BitLockerVolume |select-object mountpoint,VolumeStatus |`
    ForEach-Object {"`r`n" + $_.MountPoint + ": " + $_.VolumeStatus}))