Alert users to change their password

The following VBS script displays an alert to users at login that the password is soon to expire.

The script

' Days before to alert user 
QtDiasAviso = 7 
RedirectRdWeb = true
UrlRDWEB = "https://monserveur/RDWeb/Pages/fr-FR/password.aspx"
Message_alert = ""
Set oTranslate = CreateObject("NameTranslate") 
Set oNetwork = CreateObject("WScript.Network") 
Set wshell = WScript.CreateObject("WScript.Shell")

oTranslate.Init 3,"" 
oTranslate.Set 3, oNetwork.UserDomain & "\" & oNetwork.UserName 
Set objUserLDAP = GetObject _ 
intCurrentValue = objUserLDAP.Get("userAccountControl") 
' Check if user account have date to password expires 
If not intCurrentValue and ADS_UF_DONT_EXPIRE_PASSWD Then 
    ' Determine when password expires and calculate the days 
    ' Instead of PasswordExpirationDate, you can use the accountExpirationDate property, depending on the case 
    SenhaAlt = DateDiff("d",date,objUserLDAP.PasswordExpirationDate) 
    ' If password will expire 
    if (SenhaAlt <= QtDiasAviso) then
    Message_alert = "Votre mot de passe expire dans  " &amp; SenhaAlt &amp; " jour(s) " &amp; vbCrLf &amp; vbCrLf &amp; "Merci de le changer dès que possible"
    if(RedirectRdWeb = true) then
      Message_alert = Message_alert &amp; vbCrLf &amp; vbCrLf &amp; "Une page intranet va s'ouvrir pour vous permettre le changement"
    end if
     MsgBox Message_alert, vbExclamation,"Expiration de votre mot de passe"
    if(RedirectRdWeb = true) then
      wshell.Run UrlRDWEB
    end if
    end if 
end if


Customizing the script

line 2 :

QtDiasAviso = 7

Number of days the message begins to appear

line 3 :

RedirectRdWeb = true

True : opens the page defined in the UrlRDWEB variable when the user clicks OK

False : Close the window when the user click OK

line 4 :

UrlRDWEB = "https://monserveur/RDWeb/Pages/fr-FR/password.aspx"

URL of the page where the user can change his password.

line 29,32 :

Customizing the message that is displayed to the user.

How useful was this post?

Click on a star to rate it!

Average rating / 5. Vote count:

We are sorry that this post was not useful for you!

Let us improve this post!

Related Posts

SOPHOS XG: clientless access
Clientless access presentation Client-free access to Sophos XG firewalls allows connections to corporate servers without a VPN client by going directly through an internet browser as Citrix does. Clientless access configure Firewall configuration 1.

GPO hide drive C
Presentation In this tutorial, we'll see how to hide drive C using Group Policy (GPO). This GPO is often used to hide drives on RDS farms. Hiding the reader does not prevent access, it is possible to access the reader by the browser directly entering

RDS Farm: High Availability Service Broker Configuration
As a follow-up to the article: Deploy a RDS Windows 2012 R2 / 2016/2019 farm, we will see in this tutorial how to configure the high availability service broker. This configuration is optimized for clients use as address of connection to the RDS serv