Change a large number of accounts passwords with PowerShell

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 '[email protected]' –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


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.