none
ScriptingAgentConfig throw exception in the Enable-mailbox command RRS feed

  • Question

  • hi All,

    I am using ScriptingAgentConfig for customize new and enable mailbox. My Exchange Ver is 2013 CU17.

    However, I found the New-Mailbox cmdlet works fine but not the enable-mailbox one.

    Below is the error when trying to enable a user mailbox in EAC:

    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 is 1 message 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)‎

    Below is my ScriptingAgentConfig file:

    <?xml version="1.0" encoding="utf-8" ?>
    <Configuration version="1.0">
     <Feature Name="MailboxProvisioning" Cmdlets="new-mailbox">
      <ApiCall Name="OnComplete">
       if($succeeded)
        {
        Start-sleep 10
        $DC = [string]($readonlyiconfigurable.originatingserver)
        $user = $provisioningHandler.UserSpecifiedParameters["Name"]
        $user >> \\localshare\temp\new-create-users.txt
    $mailbox = Get-Mailbox -Identity $user
        Set-CASMailbox $mailbox -ActiveSyncEnabled $false -OWAforDevicesEnabled $false -DomainController $DC.mydomain.local
        Set-CASMailbox $mailbox -OWAEnabled $false -POPEnabled $false -DomainController $DC.mydomain.local
        Set-CASMailbox $mailbox -MAPIBlockOutlookRpcHttp $false -DomainController $DC.mydomain.local
        }
      </ApiCall>
     </Feature>
     <Feature Name="EnableMailbox" Cmdlets="enable-mailbox">
      <ApiCall Name="OnComplete">
       if($succeeded)
        {
        Start-sleep 10
        $DC = [string]($readonlyiconfigurable.originatingserver)
        $user = $provisioningHandler.UserSpecifiedParameters["Identity"]
        $user >> \\localshare\temp\new-enable-users.txt
    $mailbox = Get-Mailbox -Identity $user
        Set-CASMailbox -Identity $mailbox -ActiveSyncEnabled $false -OWAforDevicesEnabled $false -DomainController $DC.mydomain.local
        Set-CASMailbox -Identity $mailbox -OWAEnabled $false -POPEnabled $false -DomainController $DC.mydomain.local
        Set-CASMailbox -Identity $mailbox -MAPIBlockOutlookRpcHttp $false -DomainController $DC.mydomain.local
        }
      </ApiCall>
     </Feature>
    </Configuration>

    when I check the new-enable-users txt file, there is nothing inside after new mailbox enabled. the new-create-users.txt got the new create mailbox name logged BTW.

    hope someone can help me out.

    Best regards,

    • Moved by Bill_Stewart Wednesday, November 29, 2017 6:48 PM Unanswerable drive-by question
    Monday, October 23, 2017 3:53 AM