Password Expiry Email Alert Counter Days Left

Sharing this powershell Solution which you can utilize incase you want to Alert your user population before Password is expired.

You will find some of these solutions on the internet, it is not the first one but it is the one in a techwizard way

Prerequisites Modules for this solution:

Install these modules before downloading/executing the script.

Download the Solution from below Git link:

https://github.com/VikasSukhija/Downloads/blob/master/passwordexpiryalert.zip

Extract the Solution:


Update the HTML wordings/Steps as per your organization.


Note: Do not remove {0}, {1}, or {2} else script will not be able to add dynamic values to it.

Script has been parameterized so that you can just supply the values without altering the script.

[CmdletBinding()]

param

(

[Parameter(Mandatory = $true)]

$daystoexpiryleft,

[Parameter(Mandatory = $true)]

[ValidateSet($true,$false)]

$SendAlert,

[Parameter(Mandatory = $true)]

$smtpserver,

[Parameter(Mandatory = $true)]

$from,

[Parameter(Mandatory = $true)]

$erroremail,

[string]

$emailbodyfilepath = ‘./EmailBody.html’,

$countofchanges = ‘1000’,

$logrecyclelimit = ’60’

)

#####################################################################

$daystoexpiryleft
à As parameter suggest, enter the number of days you want user should start receiving alert. (15 days is optimum)

Note: User will be Alerted Everyday till he change the password or his password is expired.

$SendAlert à
Set value to $true if you want alert to be sent to users , Set value to $false in case you just want to log(can be utilized initially).

$smtpserver à smtp server name which will be used for relay.

$from
à From Address from which email will be sent to users.

$erroremail
à email address where error and logs to be sent

Rest parameters are optional:

$countofchanges
à It is threshold parameters so that script stops if it detects more number of users then this number.

$logrecyclelimit à
recycle logs after number of days

 

Example Syntax:

Send Password Expiry Alert:

.\PasswordExpiryAlert.ps1 daystoexpiryleft
15 -SendAlert $true -smtpserver smtpserver -from donotreply@labtest.com -erroremail VikasSukhija@

labtest.com -countofchanges 500 -logrecyclelimit 60

Log only Password Expiry Alert:

.\PasswordExpiryAlert.ps1 daystoexpiryleft
15 -SendAlert $false -smtpserver smtpserver -from donotreply@labtest.com -erroremail VikasSukhija@

labtest.com -countofchanges 500 -logrecyclelimit 60

Schedule it daily from windows task scheduler, here is the message alert that users will receive.


 

Thanks for reading and downloading …

Tech Wizard

https://techwizard.cloud

https://syscloudpro.com/

PowerShell Fast Track

 

Leave a comment