PowerShell Password Reminder Script Updated!

mslogoToday I finally released my updated version of the now infamous, PowerShell Password Reminder script.

It has been a long time coming, and I have tried to incorporate a lot of the feedback (if not all from the 230 Q&As from the TechNet Gallery.

Now on GitHub https://github.com/titlerequired/public

I switched away from static variables inside the script in favour of using Parameters and also changed some of the logic in how the User objects are found and processed. Instead of processing each one in turn fully we now grab the relevant accounts, work out their password expiry date and then move on. PowerShell itself then filters those who need to be notified and we then process those in turn.


New Script

I have tried to increase the usefulness of the logs, especially around the SMTP session.

In the old script, any errors in the SMTP session would only be seen when running interactively. The log would only show whether or not a user should have been notified.

Old Log Style

In the new script we will capture that error and log it.

New Log

It is not all change though! HTML customisations will still work, and it can still be run as a scheduled task.


I may go through and update all of the videos I added to my YouTube Channel to reflect the changes in the script, however as the two are still quite similar in that respect I might not, but I did post a new video with a bit of a demonstration of the new version here.

The only thing left to do is say thank you to anyone who has downloaded and is using the script, it really has been a lot of fun to work on over the last few years. My only regret is that I didn’t charge £1 for the download.

Oh, also, download it here!!

About Robert Pearman
Robert Pearman is a UK based Small Business Server enthusiast. He has been working within the SMB IT Industry for what feels like forever. Robert likes Piña colada and taking walks in the rain, on occasion he also enjoys writing about Small Business Technology like Windows Server Essentials or more recently writing PowerShell Scripts. If you're in trouble, and you can find him, maybe you can ask him a question.

19 Responses to PowerShell Password Reminder Script Updated!

  1. Christopher Giglio says:

    Robert, this Script has proven to work great through testing. However, I’m noticing something very strange. While running the script in the ISE, it successfully sends emails to which ever users qualify (I set my notifications starting at 7 days til expiration.) I can even watch the script quickly scroll through the users in the organizational units I chose to run it against while doing so. My problem is when trying to run the script from Windows task scheduler. NOTHING HAPPENS and I can’t seem to figure out why. I’ve tried using the -sta flag and still nothing. I notice it doesn’t run by right-click>run with powershell, either.

    One thing I noticed is that it worked fine (using Task Scheduler) when I was testing it with only one test OU over a weekend about a month ago. Since then I had made some changes to the script, mostly adding more OUs to run against but now it doesn’t run. I am using Version 1.4, February 2016 of your script which I can’t seem to find the original copy of anymore. Any type of advice would be greatly appreciated. Thanks in advance!

    P.S. – I Would consider myself a beginner-intermediate level powershell user if that helps.

    Windows Server 2008 R2 Datacenter
    SP1 / 64bit
    PSVersion 5.0.10586.117

    • BT says:

      Set your Actions > Program/Script to C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
      and add arguments of -file “<>\<>”

  2. Brandon says:

    Hello Robert,

    Thank you for this script I have a client that I am using it for and it works great.

    I also wanted to leave a comment about how to target specific days in the new 2.2 version, with very little scripting experience it took me a long time to figure out and though it might help someone.

    On line 141 in an unmodified version it looks like this.
    $notifyUsers = $colUsers | where { $_.DaysToExpire -le $expireInDays}

    What I did to target specific days to send the email was change the line to this.
    $notifyUsers = $colUsers | where { $_.DaysToExpire -eq “21” -or $_.DaysToExpire -eq “14” -or $_.DaysToExpire -eq “7” -or $_.DaysToExpire -eq “2” -or $_.DaysToExpire -eq “1” -or $_.DaysToExpire -eq “0” }

    Not sure if this is the easiest way, its what worked for me.

    Thank you,

  3. BT says:

    Robert, love the script. Well designed. I have it working in my primary domain, but am having an issue with my AWS domin. I am getting an error in the CSV file that says ‘A parameter cannot be found that matches parameter name ‘from’. I’ve edited the from a number of ways, but I can’t seem to get past it. The script runs without error.

  4. Dan Lonero says:

    Is there a guide to setting this up? I’m having trouble figuring out where to begin. My SMTP server requires authentication… can’t find where to set that in the script. Also is this the only script you need? I keep reading you need two scripts. Help! :)

  5. Ryan MOrrill says:

    I have not found on your webpage or in the videos where I input the information in the ver 2.7 of your Password Reminder script? I am learning…Novice!

  6. Robert says:

    Hi Robert, I have made a change which I thought you might like to look at with regards to the report, instead of adding the CSV as an attachment I add it to the email body as it saves one click for the managers :) which is always vital I find

    Line 301 add this after the {

    $htmlformat =@”

    TABLE{border-width: 3px;border-style: solid;border-color: black;border-collapse: collapse;}
    TH{border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color:#FFFFFF}
    TD{border-width: 1px;padding: 8px;border-style: solid;border-color: black;background-color:#FFFFFF}


    Then before $reportBody add

    $EmailBody = Import-Csv -Path “$logFile” | ConvertTo-Html -Head $htmlformat

    Then change the reportBody variable to your required message and add $EmailBody where ever makes sense and it will show you the CSV File in the email body.

    You can then either remove the attachment from the Send-Mailmessage line or leave it depending on your requirements.

    Hope that helps someone, thanks for this wonderful script.


  7. kammasood says:

    works great, just a request is it possible to send first email 15 days before the expiry, second 5 days before as if I set this to run everyday and users will get email daily.

  8. John Lagas says:

    Hi Robert, is it possible to update the download link because the link from TechNet is not working?

  9. Jim Gordon says:

    Great script! I have been using it for years now. Do you have any plans to update it so that it can use modern authentication in O365?

  10. TJ Sapunairch says:

    It is possible to set the subject line to RED within the scripts so it stands out? Or any other options so users don’t disregard these emails?

Leave a reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: