I want a command to run when a mailbox is made that disables some features such as POP, IMAP and Exchange ActiveSync. However, the command always fails, saying I get a null on the Identity parameter.
Summary: 1 item(s). 1 succeeded, 0 failed. Elapsed time: 00:00:00 USER Completed 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.ParameterBinderBase.ValidateNullOrEmptyArgument(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, Type argumentType, Object parameterValue, Boolean recurseIntoCollections) at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags) at System.Management.Automation.CmdletParameterBinderController.BindParameter(CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags) at System.Management.Automation.CmdletParameterBinderController.BindParameter(UInt32 parameterSets, CommandParameterInternal argument, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags) at System.Management.Automation.CmdletParameterBinderController.BindParameters(UInt32 parameterSets, Collection`1 arguments, CommandMetadata commandMetadata) at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParametersNoValidation(Collection`1 arguments) at System.Management.Automation.CmdletParameterBinderController.BindCommandLineParameters(Collection`1 arguments) at System.Management.Automation.CommandProcessor.BindCommandLineParameters(CommandParameterInternal[] parameters) at System.Management.Automation.CommandProcessor.Prepare(CommandParameterInternal[] parameters) at System.Management.Automation.CommandProcessorBase.DoPrepare(CommandParameterInternal[] parameters) at System.Management.Automation.Internal.PipelineProcessor.Start(Boolean incomingStream) at System.Management.Automation.Internal.PipelineProcessor.SynchronousExecuteEnumerate(Object input, Hashtable errorResults, Boolean enumerate) --- End of inner exception stack trace --- at Microsoft.Exchange.ProvisioningAgent.ScriptingAgentHandler.OnComplete(Boolean succeeded, Exception e) at Microsoft.Exchange.Provisioning.ProvisioningLayer.OnComplete(Task task, Boolean succeeded, Exception exception) Exchange Management Shell command completed: Enable-Mailbox -Identity 'DOMAIN.ca/Users/USER' -Alias 'USER' -Database 'Primary Mailbox Database' Elapsed Time: 00:00:01
My ScriptingAgentConfig.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
-<Configuration version="1.0">-<Feature Cmdlets="new-mailbox,enable-mailbox" Name="MailboxProvisioning"><ApiCall Name="OnComplete"> if($succeeded) { $newmailbox = $provisioningHandler.UserSpecifiedParameters["Name"] set-CASMailbox -Identity $newmailbox -MAPIBlockOutlookRpcHttp:$true -ImapEnabled:$false -OWAEnabled:$false -PopEnabled:$false -ActiveSyncEnabled:$false } </ApiCall></Feature></Configuration>
Any idea why my script is failing? I'm stumped.