Cmdletextension and its magic :)

Recently one of my dear friend asked me about a question ::: Adding a particular field for as a SMTP address for newly created users automatically.

Did I Just say Friend :) He is our PFE Akshay

Well I talked about the cmdletextension agents with him and I also liked the Idea

Then we had a great discussion about the same and then we sat in our labs to see if this is really possible.

Eureka we were able to achieve the same.

Before We talk about how we achieved it, please go through the following article about cmdletextensionagents

Now lets see how we did we do it

We wanted to have the Pager attribute value to be populated as the additional email address

<?xml version="1.0" encoding="utf-8" ?>

<Configuration version="1.0">

<Feature Name="MailboxProvisioning" Cmdlets="enable-mailbox">

  <ApiCall Name="OnComplete">

   if($succeeded) {

$user = (Get-User $provisioningHandler.UserSpecifiedParameters["Identity"]).distinguishedName

set-mailbox -identity $user -emailaddresspolicyenabled $false

$a=get-mailbox $user | Get-User | select pager

write-host $a

write-host $a.pager

$b=$a.Pager+ ""

$c=Get-Mailbox $user


Set-Mailbox -identity $user -EmailAddresses $c.EmailAddresses





I would strongly recommend you to go ahead look at the blog about where and how to enable which scripting agent.

Thanks a lot Akshay.

Naveen Vasudevan