Managing user accounts in Active Directory can be a daunting task, especially when it comes to disabling multiple accounts that are no longer in use. In this post, we will share a PowerShell script that allows you to bulk disable users in Active Directory using a CSV file as input. This simple yet powerful script will help you maintain your user accounts more effectively. At ServerEngine, we offer innovative solutions to streamline your server management processes.
powershell
Import-Module ActiveDirectory
function Disable-ADUsers {
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 "Failed to disable user: $userName. Error: $_"
}
}
}
Disable-ADUsers -csvPath "C:\Path\To\Your\users_to_disable.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.