下面的代码在到达时会一直陷入循环
$choice = read-host "Are you sure you want to disable the following user? (Y/N)" "$name"
Run Code Online (Sandbox Code Playgroud)
我键入y并继续循环该问题.
我尝试了一段时间和单一的IF语句.关于如何阻止这个循环的任何想法?
$choice = ""
$User = read-host "enter username"
$Name = Get-ADuser -Identity $Username | Select-Object Name
while ($choice -notmatch "y/n"){
$choice = read-host "Are you sure you want to disable the following user? (Y/N)" "$name"
If ($Choice -eq"Y"){
Disable-ADAccount $Username
}
}
Run Code Online (Sandbox Code Playgroud)