PowerShell跳过获取卷

PowerShell跳过获取卷,powershell,Powershell,有人能给我一些启示吗?Powershell正在跳过以下行中的Get Volume命令: ## Warning message Write-Host -ForegroundColor Red 'This application will delete all stored information on your disk. Please ensure this is what you want to do. Use with caution!' ## Get available disks Ge

有人能给我一些启示吗?Powershell正在跳过以下行中的Get Volume命令:

## Warning message
Write-Host -ForegroundColor Red 'This application will delete all stored information on your disk. Please ensure this is what you want to do. Use with caution!'

## Get available disks
Get-Volume

## Select Disk
$diskDrive = Read-Host 'Which drive do you want to format/convert?'
我尝试将其输出到变量,并尝试添加-Verbose标志。两者都不起作用。我确信这是显而易见的,但我错过了。提前感谢您的帮助。

请使用以下命令:

Get-Volume | Out-Host

问题是您的两个命令直接与PowerShell主机交互。
Get Volume
命令输出到管道(在这种情况下很可能是成功流)。主机输出不使用管道,因此无法感知同步。在您的情况下,最简单的答案是只将所有命令输出到主机。

请参阅此线程:使用
Get Volume | Out host
。谢谢大家。虽然这两个选项都有效,但最简单的是“出主机”。谢谢你的帮助!!