From ebd0cddac9bdab632560e6b989d506ede33eac1b Mon Sep 17 00:00:00 2001 From: sawft99 <81699231+sawft99@users.noreply.github.com> Date: Wed, 1 May 2024 11:17:49 -0500 Subject: [PATCH] Update ADUnlockLoop.ps1 - Formatting changes --- ADUnlockLoop.ps1 | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/ADUnlockLoop.ps1 b/ADUnlockLoop.ps1 index 4de0509..75afa84 100644 --- a/ADUnlockLoop.ps1 +++ b/ADUnlockLoop.ps1 @@ -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