Posts

Showing posts with the label Scripting Agent

Objects Available to the Scripting Agent

Image
The Scripting Agent uses $ProvisioningHandler and $readOnlyIConfigurable to represent objects available during an action. I could not find any documentation on these objects and did some experimentation. The following is my results: The variable $ProvisioningHandler contains information about the cmdlet being executed. This includes  the name of the cmdlet, parameters for the cmdlet, and the user that ran the cmdlet. The name of the cmdlet is stored in $provisioningHandler.TaskName The user running the cmdlet is stored in $provisioningHandler.UserScope.UserID The parameters passed to the cmdlet are stored in $provisioningHandler.UserSpecifiedParameters[“ PName ”] where PName is the name of the parameter that was passed. For example, Identity and Alias are common parameter names that would be used in place of PName . The variable $readOnlyIConfigurable contains the properties of the object being acted upon. For example, when using the Set-Mailbox cmdlet, $readOnlyIConfigurable ...

ScriptingAgentConfig.xml Syntax

The Scripting Agent for Exchange 2010 SP1 uses ScriptingAgentConfig.xml to define additional content used when running specified cmdlets. This file needs to be located in in C:\Program Files\Microsoft\Exchange\v14\Bin\CmdletExtensionAgents. This file uses the following generic format: Line 1 <?xml version “1.0” encoding=”utf-8”?> Line 2 <Configuration version=”1.0”> Line 3 <Feature Name=”YouPickName” Cmdlets=”CsvList”> Line 4 <ApiCall Name=”NameOfAPI”> Line 5 The script goes here Line 6 </ApiCall> Line 7 </Feature> Line 8 </Configuration> Description of example: Line 1 defines the version of XML . This line is always here and always the same. Line 2 opens the configuration tag. The configuration tag exists once in the file. Line 3 opens the feature tag. There can be multiple feature tags in the file. Each feature tag has a name that you define. The name needs to be unique, but can be anything that makes sense to you. Each feature tag also h...

Customize Exchange Cmdlets

There have been many times in class when students have asked me if there is a way to change default settings in Exchange 2010 when perform task such as creating users. If you had asked me two weeks ago, my answer would have been: “Nope. You’ll need to modify those users after you create them.” Turns out I was wrong. Exchange 2010 SP1 includes a component called the Scripting Agent. The Scripting Agent lets you define scripts that run when specific cmdlets, such as New-Mailbox, are used. Since the Exchange Management Console (EMC) runs cmdlets in the background, this will apply there too. First you need to enable the Scripting Agent: Enable-CmdletExtensionAgent “Scripting Agent” Next, you need to create an XML file that defines the scripts to be run and for which cmdlets. The file must be named ScriptingAgentConfig.xml and located in C:\Program Files\Microsoft\Exchange\v14\Bin\CmdletExtensionAgents.   I’ll post some examples later. In this post I will limit myself to describing ge...