Tuesday, July 9, 2013

Office 365 Powershell command(s) for DIRSYNC

I had an interesting session with the Office365 technical Support team and learned a few new commands today.

The first this to remember is that there are 3 possible system scenarios for running Powershell command:
  • A  system with DIRSYNCinstalled
  • An On-Premise Exchange management System
  • Any other computer with Neither of the able installed.
The goal here is to run PowerShell with the necessary privileges and Snapins to be able to perform the tasks.

At one point, the Support Technician wanted me to run "Get-Mailbox" and also "Start-OnlineCoexistenceSync".

GET-MAILBOX
The Get-Mailbox commandlet sounds easy, but remember that this is for Office365, not the on-premise Exchange.
To run this commandlet, we were able to perform the task on any PC.  (It does not need to be in the domain of the Dirsync server.)
Type to following commands:
PS C:\Windows\system32> Set-ExecutionPolicy unrestricted
PS C:\Windows\system32> $cred = Get-Credential
PS C:\Windows\system32> $session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionURI https://ps.outlook.com/powershell/ -Credential $cred -Authentication Basic -AllowRedirection
PS C:\Windows\system32> Import-PSSession $session
PS C:\Windows\system32> Get-Mailbox


Start-OnlineCoexistenceSync
 The Start-OnlineCoexistanceSync commandlet needs to be run on the server that has DIRSYNC installed.  It also must be run in Powershell with Elevated Previledges.

PS C:\Windows\system32>Add-PSsnapin Coexistence-Configuration

(Note: for this step, there is a PSC1 file in C:\Program Files\Microsoft Online Directory Sync, but the above command works.)
PS C:\Windows\system32> Start-OnlineCoexistenceSync

Note that you will not get any feedback from this command, but if you launch
"C:\Program Files\Microsoft Online Directory Sync\SYNCBUS\Synchronization Service\Bin\MIICLIENT.EXE", you will see 3 events that occur when a synchronization occurs.



No comments: