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:
Log on to ADManager Plus
Navigate to Management > User management > User templates > User creation templates.
Enter the name and description of the template.
Likewise, enter the required details in the respective tabs.
In the Custom attributes tab, check the Run custom script on successful user creation option.
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.
scr.vbs %userName%
scr.bat %userName%
"C:\ManageEngine\ADManager Plus\Scripts\SubScripts\scriptName.ps1" %userName%
scriptname.ps1 %username%
8. To use this template,
Note:
You can also run the custom script as a:
VBScript using the cscript C:\dir1\scr.vbs%userName% format.
Batch file using the scr.bat format (or scr.cmd format).
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