Force Users to change password at next logon

I was recently working on a project where users were getting new laptops issued to them and this involved users having to have their passwords changed afterwards to ensure security. Rather than do it manually I cooked up this little script with a little help from Google.

The script will look for a CSV file in the location C:\Scripts\Users.csv and will only be looking for one column called SamAccountName. If the file doesn't exist in that location or the CSV file it finds doesn't have a SamAccountName column it wont work and will fail.

If you do use the script you can always change the path manually in the script to where you have stored the CSV file. I may update the script when I get chance to put it into a variable that can be passed into the script but that's for another day.

The script will then read the contents of the CSV file and for each entry it will set the 'User must change password at next logon

Here is the script itself


Leave a Reply

Your email address will not be published. Required fields are marked *