0
votes

I'm attempting to automate a few processes with the Exchange 2010 Scripting Agent, I want to disable several mailbox functions on creation (which works just fine) and automatically export a mailbox on remove request.

<?xml version="1.0" encoding="utf-8" ?>
<Configuration version="1.0">
 <Feature Name="MailboxProvisioning" Cmdlets="new-mailbox">
  <ApiCall Name="OnComplete">
   if($succeeded)    {
    $newmailbox = $provisioningHandler.UserSpecifiedParameters["Name"]
    set-casmailbox $newmailbox -OWAEnabled:$false -ActiveSyncEnabled:$false -ImapEnabled:$false -PopEnabled:$false
   }
  </ApiCall>
 </Feature>

^ This all works

But the second section I'm wondering what ApiCall I need to use to run a command BEFORE the remove-mailbox command processed.

<Feature Name="MailboxProvisioning" Cmdlets="remove-mailbox">
  <ApiCall Name="??????">
   if($succeeded)    {
    $removedmailbox = $provisioningHandler.UserSpecifiedParameters["Name"]
    New-MailboxExportRequest -Mailbox $removedmailbox -FilePath \\exchsrv\PSTFiles
   }
  </ApiCall>
 </Feature>
</Configuration>

Any help would be greatly appreciated!

1

1 Answers

0
votes

The correct ApiCall would be 'validate'. This triggers an event after Exchange determines the used cmdlet is a valid command and has all of the info it needs. After validation succeeded but before the cmdlet is run, the scripting agent is set to work :)