【发布时间】:2022-06-17 23:51:09
【问题描述】:
期望的输出是重复问题,直到选择“Y”或“N”。
$msg = 'Does this Share contain Sensitive Data? [Y/N]'
do {
$response = Read-Host -Prompt $msg
if ($response -eq 'n') {
$sdata = "No"
}
if ($response -eq 'y') {
$sdata = "(Sensitive)"
}
} until ($response -ne '$null')
但是,如果我输入任何其他内容,它仍然会继续运行脚本。我在其他脚本上也有这个工作,所以我不确定为什么它现在不能工作。
一如既往的感谢!
【问题讨论】:
-
将
$response -ne '$null'更改为-not $response
标签: powershell until-loop