Managing user accounts effectively is essential for maintaining security in your organization. This PowerShell script allows administrators to bulk disable user accounts in Active Directory based on a list in a CSV file. By automating the account disabling process, IT departments can ensure that inactive or terminated accounts are promptly managed. At ServerEngine, we provide powerful tools to streamline your IT management tasks.
powershell
Import-Module ActiveDirectory
function Disable-ADUserAccounts {
param (
[string]$csvPath
)
$users = Import-Csv -Path $csvPath
foreach ($user in $users) {
$username = $user.UserName
try {
Disable-ADAccount -Identity $username
Write-Host "Successfully disabled user: $username"
} catch {
Write-Host "ERROR: Could not disable user: $username. Error: $_"
}
}
}
Disable-ADUserAccounts -csvPath "C:\Path\To\Your\disable_users.csv"Run it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in Active Directory
Active Directory User Onboarding with PowerShell
2026-08-17Active Directory User Offboarding with PowerShell
2026-08-17Disable an Active Directory User with PowerShell
2026-08-17Enable an Active Directory User with PowerShell
2026-08-17Unlock an Active Directory Account with PowerShell
2026-08-17Reset an Active Directory Password with PowerShell
2026-08-17Ready when you are.
Try ServerEngine free for 7 days.