Bulk password change with Powershell

Every 3 months or so I am required to change a bunch of users passwords in accordance with our security policies.  In the past, this has been a tiresome task, but over the last 6 months or so I have been improving on my Powershell skills.  Knowing that this would be achievable through a PS1 script, I set about looking through the Internet to find the solution, however I came up blank.

Through trial and error I managed to get the following working.  The csv file has two columns; name,password.  Once you have connected to a DC, authenticated with a domain admin account and imported the AD module, run this line:

import-csv C:\temp\Users.csv | foreach { set-adaccountpassword -identity $_.name -reset -newpassword (convertto-securestring -asplaintext $_.password -force)}

Works a treat!  Thought I’d share since I was unable to find anything similar on the Interwebs…