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.

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.

Params

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.

body

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.

3 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

  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,
    Brandon

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: