Let’s understand how to configure Exchange Server to send welcome email:
What is Cmdlet Extension Agents?
Cmdlet extension agents are components in Microsoft Exchange Server 2013/Exchange Server 2010 invoked by Exchange 2013/2010 cmdlets when the cmdlets run. Every time an Exchange cmdlet is run, the cmdlet calls the Scripting Agent cmdlet extension agent. When this agent is called, the cmdlet checks whether any scripts are configured to be called by the cmdlet. If a script should be run for a cmdlet, the cmdlet tries to call any APIs defined in the script. Cmdlet extension agents are available on any server role.
Implementation:
As you got an idea on the Cmdlet Extension Agent, I will go ahead and explain how we can use the feature to generate welcome email for the new mailboxes that we create.
When we create new mailbox in Exchange 2010/2013, new-mailbox command is used (whether it is Exchange Management Shell or Exchange Management Console). You can enhance the behavior of the command by using Cmdlet Extension. It is like triggering a script whenever new-mailbox command is used.
In order to use the feature, we need to,
– Deploy XML file on all the exchange servers.
– Enable “Scripting Agent”.
How to deploy XML files?
On all the exchange servers, the exchange setup copies the file “ScriptingAgentConfig.xml.sample” to <installation path>\Bin\CmdletExtensionAgents\. The file is a kind of sample/template. We can modify the file to meet our requirement or we can make our own XML file. I have detailed the steps to modify the sample file to send welcome email.
Note: The sample XML contains other feature blocks. If you are appending the below steps as it is without making changes to other feature blocks, you may receive unexpected warning while create new mailbox. If you are not using cmdlet-extension sample file for any other purpose/tasks, I would suggest you keep only the Welcome Email Feature block as it is in XML file provided in the attached zip file.
Step #1:
Create a welcome email template in html format that will be sent as welcome email or use the exiting template attached to the blog to suit your requirement. Easiest way to create welcome email template would be, open new message in Outlook, compose the email and save it as HTML.
Step #2:
Make a copy of the existing XML file and rename it to ScriptingAgentConfig.xml. Keep the file in <installation path>\Bin\CmdletExtensionAgents\.
Step #3:
Replace the following content:
- $tempmsg= [string] (get-content (“c:\welcome\WelcomeMSG.htm“))
- $HUBServer=”20.1.1.2“
- $WelcomeEMail.From=administrator@e2k10.com
- $WelcomeEMail.Subject=”Welcome to Contoso IT !!!“
How to manage/enable Cmdlet Extension Agent?
After the XML file updated with script, you need to enable the agent to call the XML file and the script whenever new-mailbox used. You can view the agent status by running the command:
Get-CmdletExtensionAgent | FT Name,Enabled
By default,“Scripting Agent” is disabled. You can enable it using the command,
Enable-CmdletExtensionAgent “Scripting Agent”
When you wanted to disable the “Scripting Agent” , run the command ,
Disable-CmdletExtensionAgent “Scripting Agent”
Enabling or disabling CmdletExtension does not require restart of the server or exchange services in a normal scenario. It is a global command and applicable to all the exchange servers in the organization. So you have to update the XML file on all the exchange servers. If the XML files is not updated on any of the exchange server and you run any non-Get cmdlets, the cmdlet will fail.
Downlod: WelcomeMSG
Related articles :
https://gallery.technet.microsoft.com/office/Send-Welcome-Email-to-New-88cde35c
http://blog.51cto.com/johnsonchen/1860377