Disabling User and Computer Accounts

To disable user, computer or service accounts, use the Disable-ADAccount cmdlet. The –Identity parameter specifies which account to disable. You can specify an account by its distinguished name, security identifier (SIDs), globally unique identifier (GUID) or Security Account Manager (SAM) account name.

Disabling a User Account

Disable-AdAccount -Identity RussellS

Disabling a Computer Account

If you specify a computer account name, remember to append a dollar sign ($) at the end of the name; otherwise, you’ll get an error after script execution.

Disable-ADAccount -Identity fs1$

Disabling Multiple Accounts in Bulk

You can also disable accounts in bulk using a list in a text file:

$Pclist = Get-Content C:\scripts\Computer.txt # Specify the path to the computer list.

Foreach($pc in $Pclist) {
  Disable-ADAccount -Identity "$pc"
  Get-ADComputer -Identity "$pc" | Move-ADObject `
    -TargetPath "OU=Disabled Computers,DC=enterprise,DC=com"
}