0
こんにちは、皆さんにはいくつかの簡単な質問がありましたが、そこには賛否両論があります。私は基本的に私にすべてのロックされたターミナルアカウントを与えるスクリプトを持っており、確認のためにそれらのロックを解除するオプションは、NULLになるまで、あるいは少なくとも~eq 1までループするのが困難です。誰かが私を正しい方向に導いてくれますか?Do WhileループのガイダンスがPSでNULLになるまで
######################################################################################################
# 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")}