Running Exchange cmdlets in ARS script modules

Hi Folks,

I'm working through ARS development in v7.3 to facilitate hybrid mailbox creation for an organization that has both an on-premises Exchange infrastructure and Exchange Online.  Unfortunately, the native functionality in 7.3 only allows for direct EXO mailbox creation and doesn't actually allow for proper hybrid mailbox creation.  I have been working with Quest on this and apparently there will be new functionality in 7.4 to address this but i cannot wait for that at this point. 

In the past i have been able to leverage what is mentioned in the SDK and simply flag "edsaEstablishEmail" and provide a targetAddress, alias, and other relevant attributes to establish an email address that points to another Exchange org, but in a hybrid scenario the "Enable-RemoteMailbox" command needs to be executed to properly configure an exchange object that is then synchronized to Azure and over to Exchange online to create a mailbox that is in the right state.  This brings me to two questions/options that i am having a hard time answering:

  • Is there a different attribute or option set that i can set in ARS that will trigger it to execute the "enable-remotemailbox" command via its remote Exchange Management shell session?  flagging edsaEstablishEmail appears to execute "Enable-MailUser" which is not the same as "enable-remotemailbox".
  • Barring the above - is there some way through a script module to leverage ARS's existing remote Exchange Management Shell session to execute the command without me having to instantiate my own pssession in code?  I REALLY don't want to have to create my own pssession in code as it is time consuming and i have concerns about how to manage the session with concurrent usage as i have ~130 admins that could be requesting a mailbox creation at any given time.

To further the 2nd question - the documentation isn't clear on if ARS establishes an Exchange session on demand when a command is called or when the service is started.  I did validate that i cant simply execute the command, it throws an error that the cmdlet isnt recognized, which tells me that the exchange management shell isn't implicitly available in the powershell session running under the ARS context.  I am hoping there is some easy option i am missing to leverage the exchange session either indirectly to cause it to fire an "enable-remotemailbox" command or directly so i can execute that in code without having to manage my own remote management shell instance.

Thanks in advance for your help/commentary :)

  • Currently, the only way to instantiate the required cmdlets is to launch a remote Powershell session with an on-premises Exchange server that is at the correct version to support Enable-RemoteMailbox.

    It's likely that an upcoming version of Active Roles will have the Enable-RemoteMailbox type functionality implemented in a fashion similar to the way the on-premises functionality works today.

    In the meantime, the management of the remote sessions isn't too bad.  I just make sure that I fire this code snippet before I initiate the session and right after I am finished with it:

    Get-PSSession | Where-Object {$_.ComputerName -like "$MyExchangeServer*"} | Remove-PSSession

  • A further thought on the above issue you identified (so many admins firing up these PoSh sessions...)

    Rather than provisioning the Remote Mailbox immediately when the admin creates the user, set a virtual attribute "flag" (example:  edvsaNeedRemoteMailbox).  Create a schedule task script to run say every 15 minutes that searches for objects with this flag set and have it fire one Posh session to process all the queued user objects.