Powershell PS中执行While循环直到NULL的指南

Powershell PS中执行While循环直到NULL的指南,powershell,powershell-2.0,powershell-3.0,powershell-4.0,Powershell,Powershell 2.0,Powershell 3.0,Powershell 4.0,大家好,再次回到这里,为你们专业人士提出一些简单的问题,这对我们这些菜鸟来说是很难理解的。我有一个脚本,我已经为我的工作,基本上给了我所有锁定的终端帐户和选择解锁他们与确认,但我有一个困难的时间让它循环,直到NULL或至少-eq 1。有人能指引我正确的方向吗 ###################################################################################################### # Written by CPin

大家好,再次回到这里,为你们专业人士提出一些简单的问题,这对我们这些菜鸟来说是很难理解的。我有一个脚本,我已经为我的工作,基本上给了我所有锁定的终端帐户和选择解锁他们与确认,但我有一个困难的时间让它循环,直到NULL或至少-eq 1。有人能指引我正确的方向吗

######################################################################################################
# Written by CPineda
# This Script searches for all locked terminals and unlocks them accordingly 
# Last revision 04-28-2016
######################################################################################################

# Import Powershell AD Module
Import-Module activedirectory

# Search the windows terminals OU and display results
$ToSearch = "OU=ANOU,OU=ANOU,DC=DOMAIN,DC=LOCAL"
Search-ADAccount -LockedOut -SearchBase $ToSearch | Select-Object -Property Name,LockedOut,SamAccountName | Sort-Object -Property Name | Format-Table -AutoSize

# Search the windows terminals OU and display results 
$ToSearch = "OU=ANOU,OU=ANOU,DC=Domian,DC=LOCAL"
Search-ADAccount -LockedOut -SearchBase $ToSearch | Select-Object -Property Name,LockedOut,SamAccountName | Sort-Object -Property Name | Format-Table -AutoSize

# Enter the account to unlock.
Read-Host “Enter the Terminal account to unlock” | Unlock-ADAccount -Confirm -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue

# Prompt user if they want to unlock an account again
$UserInput = Read-Host -Prompt "`n`nWould you like to unlock another account (Y/n)"


  if ($UserInput -eq "Y") {

Do {

# Search the windows terminals OU and display results
$ToSearch = "OU=ANOU,OU=ANOU,DC=DOMAIN,DC=LOCAL"
Search-ADAccount -LockedOut -SearchBase $ToSearch | Select-Object -Property Name,LockedOut,SamAccountName | Sort-Object -Property Name | Format-Table -AutoSize

# Search the windows terminals OU and display results 
$ToSearch = "OU=ANOU,OU=AnOU,DC=DOMAIN01,DC=LOCAL"
Search-ADAccount -LockedOut -SearchBase $ToSearch | Select-Object -Property Name,LockedOut,SamAccountName | Sort-Object -Property Name | Format-Table -AutoSize

# Enter the account to unlock.
Read-Host “Enter the Terminal account to unlock” | Unlock-ADAccount -Confirm -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue}

Until ($UserInput -ge $null + "N")}

我对最初的问题思考了一英里,我试图为空的不必要的变量创建一个循环。最后,当我进一步思考语法时,解决方案就清楚了