Skip to content

Exchange 2010: automatic welcome message for a new user


If you need to send a welcome message to every new Exchange user, you are in the right place and I will explain why. A wiser method to do this is «Exchange Cmdlet Extension Agent». At the moment I wrote this article there was no comprehensive solution for this task on the Internets. The main problem I met is that user mailbox can be created using two cmdlets: new-mailbox and enable-mailbox. First one works well, but when you try to do the same scripting with Enable-Mailbox cmdlet, everything fails. If you are new to powershell scripting, just use my script, it should work fine. If you faced the same problem already and didn’t find solution then you should understand what really happens in that Exchange server while reading the script.

Basic steps to configure welcome message on Exchange 2010 server:

1. Place the following script on every Exchange server in your Exchange organization (except Transport server role) in to the following folder: «C:\Program Files\Microsoft\Exchange Server\V14\Bin\CmdletExtensionAgents\ScriptingAgentConfig.xml». Please be attentive to not start step 2 before working version of the script is in the folder.

<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
<Feature Name="WelcomeEmail" Cmdlets="New-Mailbox,Enable-Mailbox">
<ApiCall Name="OnComplete">
if($succeeded) {
 # Waiting for synchronization after mailbox has been created.
 Set-ADServerSettings -ViewEntireForest $true
 Start-Sleep -s 10
 # New-Mailbox triggered. Taking SamAccountName parameter.
 if ($provisioningHandler.UserSpecifiedParameters.Contains("SamAccountName") -eq $true) {
 $UsrSamAccountName = $provisioningHandler.UserSpecifiedParameters["SamAccountName"]
 $UsrAlias = (Get-Mailbox -Filter {SamAccountName -eq $UsrSamAccountName}).Alias.ToString()
 # Enable-Mailbox triggered. Taking Identity parameter, this is the only one avalaible in this case.
 if ($provisioningHandler.UserSpecifiedParameters.Contains("Identity") -eq $true) {
 $UsrIdentity = $provisioningHandler.UserSpecifiedParameters["Identity"].ToString()
 $UsrAlias = (Get-Mailbox -Identity $UsrIdentity).Alias.ToString()
 # Defining variables.
 $UsrAddr = (Get-Mailbox -Filter {Alias -eq $UsrAlias}).PrimarySmtpAddress.ToString()
 $UsrOU = (Get-Mailbox -Filter {Alias -eq $UsrAlias}).OrganizationalUnit
 # Sending email notification to the user in specific OU.
 if ($UsrOU -match "DOMAIN.LOCAL/OrganizationalUnit") {
 $UsrMsg = [string](Get-Content ("c:\scripts\WelcomeMessage.html"))
Send-MailMessage -SmtpServer "MAILER.DOMAIN.LOCAL" -To "$UsrAddr" -From "welcome@DOMAIN.LOCAL" -Subject "Welcome to our company!" -Body $UsrMsg -BodyAsHtml -Encoding ([System.Text.Encoding]::UTF8)
 # Clearing variables. Each one in its own line in order to prevent error messages from being shown on EMC.
 if ($UsrAlias) { Remove-Variable UsrAlias }
 if ($UsrAddr) { Remove-Variable UsrAddr }
 if ($UsrOU) { Remove-Variable UsrOU }
 if ($UsrMsg) { Remove-Variable UsrMsg }
 if ($UsrIdentity) { Remove-Variable UsrIdentity }
 if ($UsrSamAccountName) { Remove-Variable UsrSamAccountName }

This script assumes that welcome message body is placed in «c:\scripts\WelcomeMessage.html» on every Hub Transport server. Don’t forget to edit parameters marked with red.

2. Enable Scriptng Agent extension on the Exchange infrastructure.

Enable-CmdletExtensionAgent "Scripting Agent"

3. Restart every Exchange Management Console/Shell that already runs.

4. Try to create/enable a new mailbox user. This should do the trick.


From → Exchange, Powershell

4 комментария
  1. if don’t want to all user’s not the user in specific OU then what parameters I have to chenge

Trackbacks & Pingbacks

  1. Exchange: Send Welcome Email to New Mailbox / New Users – Cmdlet Extension Agents | MS Tech BLOG
  2. Batch Import Public Holidays into All Users Mailboxes with Exchange EWS Powershell | Welcome to

Добавить комментарий

Заполните поля или щелкните по значку, чтобы оставить свой комментарий:


Для комментария используется ваша учётная запись Выход / Изменить )

Фотография Twitter

Для комментария используется ваша учётная запись Twitter. Выход / Изменить )

Фотография Facebook

Для комментария используется ваша учётная запись Facebook. Выход / Изменить )

Google+ photo

Для комментария используется ваша учётная запись Google+. Выход / Изменить )

Connecting to %s

%d такие блоггеры, как: