Skip to main content
AD Academy
Back to all recipes
Level: MidLast updated:

Bulk-reset passwords from a CSV list

Import-Csv users.csv | ForEach-Object {
  $pwd = ConvertTo-SecureString $_.Password -AsPlainText -Force
  Set-ADAccountPassword -Identity $_.SamAccountName -Reset -NewPassword $pwd
  Set-ADUser -Identity $_.SamAccountName -ChangePasswordAtLogon $true
}

Why it works this way

After an incident or for a whole department, doing it by hand is impossible.

Caution

Destructive: it locks out dozens of people at once. Run only in an approved window, after a -WhatIf pass, with the account list saved.

Watch out

  • Test with -WhatIf on a single row first.
  • Do not keep the password file — delete it afterwards.

Related events