# Bulk unlock users from CSV (SAMAccountName list) $users = Import-Csv "locked_users.csv" foreach ($user in $users) try $adUser = Get-ADUser -Identity $user.SAMAccountName -Properties LockedOut if ($adUser.LockedOut) Unlock-ADAccount -Identity $adUser Write-Host "Unlocked: $($adUser.SAMAccountName)" -ForegroundColor Green else Write-Warning "$($adUser.SAMAccountName) is not locked"
catch Write-Error "Failed on $($user.SAMAccountName): $_" active directory users and computer
Here’s a structured plan to build a for managing Active Directory Users and Computers , whether you're enhancing an existing tool, building a new one, or integrating AD management into an application. # Bulk unlock users from CSV (SAMAccountName list)