How To Use Toast Notifications For Password Expiry Warnings With PowerShell
Think you can do better? Show us!
Do you get calls from user’s every Monday morning complaining that “the system” has locked them out. They’ll swear black and blue that their computer never warned them their password was about to expire. They won’t listen when you try to tell them about the notifications build into windows, they may as well be invisible to end users. Toasts are the native method for displaying notifications in Windows 10. In this rough cut video, Josh demonstrates how to display a notification when a user’s password is close to expiry. This scenario makes use of the Get-ADUser cmdlet from the ActiveDirectory module as well as BurntToast community module. Prerequisites include: BurntToast PowerShell Module, install via the PowerShell GalleryThis video is a Rough Cut. Rough cuts are raw, unedited videos that are provided as-is from the contributor. They do not reflect the majority of videos on videos.io. Even though the quality may be rough, the content is still valuable and thus provided to you, our viewer.
the snap we're going to look at how to use toast notifications for password expiry warnings with powershell. To do this, you need the burnt toast powershell module, which you can install from the powerShell Gallery. The first thing we need to do is find out when the user's password is going to expire. We're going to do this using the net user command rather than the commands from the Active Directory module. We're doing this because we don't want to ship the Active Directory module to each of our users workstations. However, you'll see that the output from the user is a string, which includes extra information that we don't need. To deal with it, we're going to convert this output to a string replace the words password expires trim any extra white space and then cast it as a datetime object. We should now see that we have a date time object, reflecting that this user's password is due to expire on August 19th. We can now use the time span, object to find out how much time we have between now and when the password expires in this case, we have 4 days. In 22 hours. So now we're going to apply some logic and we were only going to notify users if their password is due to expire within the next 5 days. Rule also check to see whether or not. We have a full 24 hours or more left. And if we do. We'll tell the user the count of how many days there are remaining. And will use a display units of days, otherwise give the user. The Count of hours to go and will use the unit hours. Finally we use the new burnt toast notification command coming from the burnt toast module. And we specifying an alarm sound this means that the toast notification is going to stay on the screen longer. With a much more annoying noise, hopefully this means the user will acknowledge the alert and change the password finally will include some text to tell the user why they’re being notified namely will tell them that their password is expiring soon. Will then tell them how long it is until their password does expire? And then how they can change it preemptively so if we run that last part of our example. We received the toast notification with the looping sound. And it will stay on the screen for a long time or until the user has dismissed it. You can now distribute this script via the users startup directory or as a logon script or you can run it on a schedule regardless of how you distribute it. You've now provided hard to ignore notifications to your stuff and that's been How to use toast notifications for password expiry warnings using PowerShell. Thank you for watching.