Skip to content

Commit

Permalink
Update ADUnlockLoop.ps1
Browse files Browse the repository at this point in the history
- Formatting changes
  • Loading branch information
sawft99 authored May 1, 2024
1 parent ff547a1 commit ebd0cdd
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ADUnlockLoop.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@ $User = 'user@example.com' # UPN formatting
[int]$Loops = 0 # 0 = infinite
$LogOption = $true
$LogFolder = 'C:\Logs'
#Will create a log called 'Unlock-UserNameHere.txt'
$LogLocation = $LogFolder + '\Unlock-' + ($User -split '@')[0] + '.txt'

$DomainControllers = (Get-ADGroupMember 'Domain Controllers').Name

#----------

$User = Get-ADUser -Filter {UserPrincipalName -like $User}
if ($null -eq $User) {
Write-Host -ForegroundColor Red 'User does not exist'
exit 1
}

Clear-Host

Write-Host "
=================
Unlock User Loop
=================
User: $($User.SamAccountName)
"

$User = Get-ADUser -Filter {UserPrincipalName -like $User}
if ($null -eq $User) {
Write-Host -ForegroundColor Red 'User does not exist
'
exit 1
} else {
Write-Host "User: $($User.SamAccountName)
"
}


function CheckLockStatus {
$Status = foreach ($Server in $DomainControllers) {
Start-Sleep $ServerDelay
Expand Down

0 comments on commit ebd0cdd

Please # to comment.