简体   繁体   English

如何让 PowerShell 等到命令的 output 显示出来?

[英]How to make PowerShell wait till output of the command is shown?

How to make powershell show output of the second command before executing the third command?如何让 powershell 在执行第三条命令之前显示第二条命令的 output?

Write-Host 'List of disks:'
Get-PhysicalDisk
$number = Read-Host -Prompt 'Please choose number from disks above:'

Explicitly piping your output to an Out-* or Format-* command usually causes PowerShell to finish outputting synchronously:将 output 显式传送到Out-*Format-*命令通常会导致 PowerShell 同步完成输出:

Write-Host 'List of disks:'
Get-PhysicalDisk |Out-Default # or `...|Format-Table`
$number = Read-Host -Prompt 'Please choose number from disks above:' 

You can use the pause command within a computer batch file.您可以在计算机批处理文件中使用pause命令。 It allows the computer to pause the currently running batch file until the user presses any key.它允许计算机暂停当前运行的批处理文件,直到用户按下任意键。

so, after the second command use pause in the next line and then enter third command in the script.因此,在第二个命令之后,在下一行使用pause ,然后在脚本中输入第三个命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM