Skip to content

Instantly share code, notes, and snippets.

@miticojo
Created July 27, 2016 06:56
Show Gist options
  • Save miticojo/8a0bb160681e1a46130f821ef3db14c7 to your computer and use it in GitHub Desktop.
Save miticojo/8a0bb160681e1a46130f821ef3db14c7 to your computer and use it in GitHub Desktop.
AD massive enable and change expired password
# This script apply a massive change of password and unlock users
Import-Module ActiveDirectory
# Set OU on which you need to apply massive change
$ou="...DC=company,DC=loc"
# Set password to set
$securePwd=ConvertTo-SecureString -String "NewPassword" -Force -AsPlainText
Get-ADUser -SearchBase $ou -Filter 'PasswordExpired -eq $true' | Set-ADAccountPassword -NewPassword $securePwd
Search-ADAccount -SearchBase $ou -LockedOut | Unlock-ADAccount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment