【问题标题】:PowerShell skips Get-VolumePowerShell 跳过 Get-Volume
【发布时间】:2020-09-17 04:44:45
【问题描述】:

有人可以在这里给我一些见解吗? 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 标志。两者都不起作用。我确信这很明显,但我错过了。提前感谢您的帮助。

【问题讨论】:

标签: powershell


【解决方案1】:

使用以下内容:

Get-Volume | Out-Host

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

【讨论】:

    猜你喜欢
    • 2021-05-02
    • 1970-01-01
    • 2020-06-02
    • 2017-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多