How to trigger custom scripts from ADManager Plus?

How to trigger custom scripts from ADManager Plus?

You can run scripts to perform any custom actions, as per your organization's needs, as a follow up to any Active Directory management operation performed using ADManager Plus. For example, if you want a team's manager to be notified every time an employee is provisioned for the team or send a welcome email containing the AD username and password to a new employee, you can do so by adding a custom script for it in the user creation template. The following steps will guide you with setting up custom scripts: 

  1. Log on to ADManager Plus

  2. Navigate to Management > User management > User templates > User creation templates.

  3. Enter the name and description of the template.

  4. Likewise, enter the required details in the respective tabs.

  5. In the Custom attributes tab, check the Run custom script on successful user creation option.

  6. In the Script Command text box that opens up on selecting the run custom script option, specify the location of the script in one of the formats below.

    1. cscript c:\dir1\scr.vbs %userName%

    2. cscript c:\dir~1\scr.vbs %userName%

    3. cscript scr.vbs %userName%

Note: Instead of specifying a naming format, you can explicitly specify the user name; in this case you must provide the path in the following format:

cscript "c:\dir 123\scr.vbs" testuser

  1. Click Save Template. 

Sample script for sending welcome emails to newly provisioned users

 

Set objEmail = CreateObject("CDO.Message")

objEmail.From = "xxxx@domain.com" 'Specify the From Address

objEmail.To = wscript.Arguments(2) 'Specify the To Address

objEmail.Subject = "User Created in AD" 'Subject

'Define the body of mail. Use "vbCRLF"  for new line.Use "wscript.Arguments(0)" for first argument and "wscript.Arguments(1)" for second argument

objEmail.Textbody = "Dear XXXXXX,"& vbCRLF & "The following user is created in AD."& vbCRLF & vbCRLF & "UserName:"&wscript.Arguments(0)& vbCRLF & "Password:"&wscript.Arguments(1)

objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP" 'Specify the SMTP server

objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'Specify the SMTP Port.Default port is 25

objEmail.Configuration.Fields.Update

objEmail.Send

 

Tune in next week for another quick article to help you manage your Active Directory efficiently.

Cheers,
Team ADManager Plus