Password Expiration Login script vba
VBA Code to check for password expiry and display a message if the password expires in the next 10 days.
Add-Type -AssemblyName PresentationFramework
curruser=Get−ADUser−Identity
env:username -Properties 'msDS-UserPasswordExpiryTimeComputed','PasswordNeverExpires'
if ( -not curruser.'PasswordNeverExpires') {
timediff=(new-timespan -start (get-date) -end ([datetime]::FromFileTime($curruser."msDS-UserPasswordExpiryTimeComputed"))).Days
if ($timediff -lt 5)
{
$msgBoxInput = [System.Windows.MessageBox]::Show("Your password expires in "+ $timediff + " days!`nDo you want to change it now?","Important!","YesNo","Warning")
switch ($msgBoxInput)
{
'Yes'
{
cmd /c "explorer shell:::{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}"
}
'No' { }
}
}
}
No comments to display
No comments to display