Change a large number of accounts passwords with PowerShell

Find out the simple PowerShell to bulk change passwords in AD.

John Savill

December 22, 2016

1 Min Read
Change a large number of accounts passwords with PowerShell

Q. I have a large number of accounts that I have to change periodically, what is an easy way to do it?

A. I had a customer who had a large number of room accounts that all had the same password and had to be changed every 6 months. Came up with a very simple PowerShell script that changed the passwords based on the old and new passwords (they did not want random passwords as people would have to type these in to connect to Skype for Business). In the script you would change the account names in the RoomArray and the old and new passwords. I would run this from a machine joined to the same domain as the room accounts and it had the Remote Server Administration Tools installed which enabled access to the AD PowerShell module.

$OldPass = ConvertTo-SecureString –String 'OldPassword1!' –AsPlainText –Force$NewPass = ConvertTo-SecureString –String 'NewPassword2@' –AsPlainText –Force$RoomArray = ('account1','account2','account3','account4','account5','account6','account7','account8')foreach($Room in $RoomArray){    Write-Output "Changing password for $Room"    Set-ADAccountPassword -Identity $Room -OldPassword $OldPass -NewPassword $NewPass}

 

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like