none
Script Agent Exchange 2010 sp3 ru6 RRS feed

  • Question

  • Hi,

    i've got some problem with my script agent in Exchange 2010.

    Th problem is if i add a 1 user over EMC (enable-mailbox) the script agent works perfectly but i want to add more then one user i get some warnings and the user will be added without changes. 

    I hope anybody can give me a tip where my mistake is. I post my agent and the warnings.

    <?xml version="1.0" encoding="utf-8" ?>
    <Configuration version="1.0">
     <Feature Name="Enable-Mailbox" Cmdlets="Enable-Mailbox">
      <ApiCall Name="OnComplete">
    	if ($succeeded) 
    	{
    		Start-sleep 10
    		Set-ADServersettings -ViewEntireForest $true
    		$USER = $provisioningHandler.UserSpecifiedParameters["Alias"]
    		$OU = (Get-User -Identity $USER).OrganizationalUnit
    		$ATT = (Get-mailbox -Identity $USER).customattribute1
    		$emailad = (get-Mailbox -Identity $USER).PrimarySmtpAddress
    		$emailmsg = [String] (Get-Content ("D:\scripts\willkommen.htm"))
    		
    		if (($OU -eq "xxxxxxxxxxxxxxxxxxxxxxx") -and ($ATT -eq "extern"))	{
    				Enable-Mailbox -Identity $USER -Archive -ArchiveDatabase ArchivMDB
    				Set-CASMailbox -Identity $USER -PopEnabled $false -ImapEnabled $false
    				Set-Mailbox -Identity $USER `
    					-SingleItemRecoveryEnabled $true `
    					-UseDatabaseQuotaDefaults $false `
    					-IssueWarningQuota 450MB `
    					-ProhibitSendQuota 500MB `
    					-ProhibitSendReceiveQuota 550MB `
    					-ArchiveQuota 1GB `
    					-ArchiveWarningQuota 800MB `
    					-UseDatabaseRetentionDefaults $false `
    					-RetainDeletedItemsFor "30.00:00:00" `
    					-AddressBookPolicy "xxxxxxxxxxxxxxxxxxx"
    	    } elseif (($OU -eq "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx") -and ($ATT -ne "extern")){
    				Enable-Mailbox -Identity $USER -Archive -ArchiveDatabase ArchivMDB
    				Set-CASMailbox -Identity $USER -PopEnabled $false -ImapEnabled $false
    				Set-Mailbox -Identity $USER `
    					-SingleItemRecoveryEnabled $true `
    					-UseDatabaseQuotaDefaults $false `
    					-IssueWarningQuota 900MB `
    					-ProhibitSendQuota 1GB `
    					-ProhibitSendReceiveQuota "1,1GB" `
    					-ArchiveQuota 2GB `
    					-ArchiveWarningQuota "1,8GB" `
    					-UseDatabaseRetentionDefaults $false `
    					-RetainDeletedItemsFor "30.00:00:00" `
    					-AddressBookPolicy "xyxyxyxyxyxyxyx"
    		}elseif (($OU -eq "xyyyyxyxxyxxyx") -and ($ATT -eq "extern")){
    				Set-CASMailbox -Identity $USER -PopEnabled $false -ImapEnabled $false
    				Set-Mailbox -Identity $USER `
    					-SingleItemRecoveryEnabled $true `
    					-UseDatabaseQuotaDefaults $false `
    					-IssueWarningQuota 180MB `
    					-ProhibitSendQuota 200MB `
    					-ProhibitSendReceiveQuota 220MB `
    					-UseDatabaseRetentionDefaults $false `
    					-RetainDeletedItemsFor "21.00:00:00" `
    					-AddressBookPolicy "yyyyyyyyyyy"
    		}elseif (($OU -eq "yyyyyyyyyyyyyy") -and ($ATT -ne "extern")){
    				Set-CASMailbox -Identity $USER -PopEnabled $false -ImapEnabled $false
    				Set-Mailbox -Identity $USER `
    					-SingleItemRecoveryEnabled $true `
    					-UseDatabaseQuotaDefaults $false `
    					-IssueWarningQuota 450MB `
    					-ProhibitSendQuota 500MB `
    					-ProhibitSendReceiveQuota 550MB `
    					-UseDatabaseRetentionDefaults $false `
    					-RetainDeletedItemsFor "21.00:00:00" `
    					-AddressBookPolicy "yxyxyxyx"
    		}
    		Get-MailBox -Identity $USER | Fl > d:\$USER.txt
    		((Get-MailBox -Identity $USER).recipientType -eq "UserMailbox")			
    		Send-MailMessage -From "xxxxxxxxxxxx" -To $emailad -SMTPServer "xxxxxx" -Subject "Willkommen! :-)" -Body $emailmsg -BodyAsHTML -Encoding $([System.Text.Encoding]::UTF8) -Attachments "D:\scripts\Zertifikat.zip"
    	} 
    	</ApiCall>
      </Feature>
    </Configuration>

    and here the warnings

    Summary: 2 item(s). 2 succeeded, 0 failed.
    Elapsed time: 00:00:23
    
    
    Angela Trovato
    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 validate argument on parameter 'To'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.. ---> System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'To'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. ---> System.Management.Automation.ValidationMetadataException: The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
       at System.Management.Automation.ValidateNotNullOrEmptyAttribute.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
       at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
       --- End of inner exception stack trace ---
       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:
    'xxxxxxxxxxxxxxxxxxxxxxxx Angela Trovato' | Enable-Mailbox
    
    Elapsed Time: 00:00:12
    
    
    Franz Traut
    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 validate argument on parameter 'To'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.. ---> System.Management.Automation.ParameterBindingValidationException: Cannot validate argument on parameter 'To'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. ---> System.Management.Automation.ValidationMetadataException: The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
       at System.Management.Automation.ValidateNotNullOrEmptyAttribute.Validate(Object arguments, EngineIntrinsics engineIntrinsics)
       at System.Management.Automation.ParameterBinderBase.BindParameter(CommandParameterInternal parameter, CompiledCommandParameter parameterMetadata, ParameterBindingFlags flags)
       --- End of inner exception stack trace ---
       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:
    'yyyyyyyyyyyyyyyyyyyyyyy Traut' | Enable-Mailbox
    
    Elapsed Time: 00:00:10
    thanks a lot for your feedback.


    • Edited by M. Knopf Tuesday, October 28, 2014 7:06 PM
    Tuesday, October 28, 2014 7:05 PM

All replies