Hi,
I've already posted this once at the location below, but Ed Crowley advised me to re-post here
Here's my question:
I've got a problem trying to get the Exchange Scripting Agent to work. I've seen many posts from various places on this, but none of them seem to work for me, so rather than trying to hijack someone else's post, I just thought I'd post my own.
Firstly, my setup. I've got a forest root domain with two child domains. In one child domain are the exchange servers and the other child domain hosts the customer user accounts. I've got a mix of Exchange 2010 and 2013 servers (2010 SP3 and 2013 SP1).
The code I'm using for the scripting agent is this as below. It's run in a completely virtualized environment, which is why I specified the domain controller (slow replication between the DCs)
===== START OF SCRIPT =====
<?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
$DomainController = dev-dc-v03.resource.devdomain.dev
Set-CASMailbox $user -OWAMailboxPolicy "Standard User" -DomainController $DomainController
Set-Mailbox $user -RetentionPolicy "Mailbox Retention Policy (DEV)" -DomainController $DomainController
}
</ApiCall>
</Feature>
<Feature Name="MailboxProvisioning" Cmdlets="new-mailbox">
<ApiCall Name="OnComplete">
if($succeeded)
{
$user = (Get-User $provisioningHandler.UserSpecifiedParameters["Name"]).distinguishedName
$DomainController = dev-dc-v03.resource.devdomain.dev
Set-CASMailbox $user -OWAMailboxPolicy "Standard User" -DomainController $DomainController
Set-Mailbox $user -RetentionPolicy "Mailbox Retention Policy (DEV)" -DomainController $DomainController
}
</ApiCall>
</Feature>
</Configuration>
===== END OF SCRIPT =====
I got this code from a forum somewhere (sorry, can't remember where). I've tried various versions of code though.
When I either create a new mailbox or mail enable an existing account, I get this:
===== START OF ERROR =====
The cmdlet extension agent with the index 5 has thrown an exception in OnComplete(). The exception is: Microsoft.Exchange.Provisioning.ProvisioningException: ScriptingAgent: Exception thrown while invoking scriptlet for OnComplete API: Cannot bind argument
to parameter 'Identity' because it is null.. ---> System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'Identity' because it is null. at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object
input, Hashtable errorResults, Boolean enumerate) at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections,
FunctionContext funcContext) at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) --- End of inner exception
stack trace --- at Microsoft.Exchange.ProvisioningAgent.ScriptingAgentHandler.OnComplete(Boolean succeeded, Exception e) at Microsoft.Exchange.Provisioning.ProvisioningLayer.OnCompleteImpl(Task task, Boolean succeeded, Exception exception)
button. There are 1 messages in the pop-up window. 1: Warning,The cmdlet extension agent with the index 5 has thrown an exception in OnComplete(). The exception is: Microsoft.Exchange.Provisioning.ProvisioningException: ScriptingAgent: Exception thrown
while invoking scriptlet for OnComplete API: Cannot bind argument to parameter 'Identity' because it is null.. ---> System.Management.Automation.ParameterBindingValidationException: Cannot bind argument to parameter 'Identity' because it is null.
at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate) at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][]
pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame
frame) --- End of inner exception stack trace --- at Microsoft.Exchange.ProvisioningAgent.ScriptingAgentHandler.OnComplete(Boolean succeeded, Exception e) at Microsoft.Exchange.Provisioning.ProvisioningLayer.OnCompleteImpl(Task task, Boolean succeeded,
Exception exception)
===== END OF ERROR =====
Its a 2013 user that I'm trying to create, but the ScriptingAgentConfig.xml is present on both 2010 and 2013 servers.
I'm at a loss on what to do now. I've tried this in a much simplified lab with only one domain and it works fine, but in my corporate development lab (with multiple domains) it consistently fails.
Any help or guidance would be much appreciated.
Thanks