【问题标题】:powershell until loop not working as intendedpowershell until 循环无法按预期工作
【发布时间】: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


猜你喜欢
  • 1970-01-01
  • 2018-01-26
  • 1970-01-01
  • 1970-01-01
  • 2021-09-12
  • 2013-10-15
  • 2015-02-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多