Office 365 Move Report

I have been doing a lot of Office 365 lately and I’ve been getting very “tired” of checking the status of mailbox moves at night. I get on the pc, check the status of the moves, then go back to the family. Yea, right…. I check the moves, go to youtube, and 40 mins later my wife asks “Have I lost you again to the box?”

I have to first connect to the cloud with the three magical commands in powershell.

 $O365Cred = Get-Credential
 $O365Session = New-PSSession –ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $O365Cred -Authentication Basic -AllowRedirection
 Import-PSSession $O365Session

The script emails me a progress report of mailbox moves every 10 mins. It needs to “relay out”, so I make sure I’m either pointing to the exchange server (or another server) that allows me to do this.

The “how many times it emails me” can be changed by modifying the do-while loop parameter. Currently the loop is set to 5 times. {while ($i -le 6)}
The “how often it emails me” can be changed by modifying the Start-Sleep parameter, which is set to 600 seconds {Start-Sleep -s 600}
Change the smtp server from   $smtpServer = “”   to the server that will relay for you. Change the From and To addresses to your liking, and you are all set.

I was able to check my email account and see updates from my phone.

Here is the script:

$i = 1
 do {
#Get Statistics on move requests, sort by percent complete
$Moves= Get-MoveRequest | Get-MoveRequestStatistics | select-object Alias, TotalInProgressDuration,PercentComplete| sort-object PercentComplete
$Moves  |ConvertTo-Html |out-file Moves.htm
#So i know what's happening, I have it write to the screen that it's sending mail
Write-Host "Sending Email"
     #SMTP server name
      $smtpServer = ""
     #Creating a Mail object
      $msg = new-object Net.Mail.MailMessage
     #Creating SMTP server object
      $smtp = new-object Net.Mail.SmtpClient($smtpServer)
     #Email structure 
      $msg.From = ""
      $msg.ReplyTo = ""
      $msg.subject = "MoveReport"
      $msg.IsBodyHTML = $true
      $msg.body = get-content .\moves.htm
     #Sending email 

#Pause for 600 seconds (10 mins) 
Start-Sleep -s 600
 while ($i -le 6)

DirSync generates 10,000 email alerts

While DirSync is a nice canned version of FIM, I have found it can run in a wild loop. By Default the DirSync tool runs every 3 hours. If there are any errors, it generates an email to the technical contact’s email within the tenant configuration.

I was able to make it generate about 2 or 3 email conflict reports per second. That equates to 10,000+ emails in an hour.What caused this? Having an active directory forest with multiple domains. To understand let’s say there are two bob jones. One with a default UPN of and, and let’s say for clarity these are also represented by the names chicago\bjones and madison\bjones, as in domain\samaccountname. Technically there is no conflict. The UPNs are unique across the forest and the samaccountnames are unique within each respective domain.

Using a powershell command I can set the UPN suffix to for both accounts. It should be noted that the ADUC utility will prevent conflicts from occurring, thus allow changing the first one to, but then prevent the second one from being changed to

After there became two UPNs, DirSync found itself in a loop. When it generates a sync report to the technical contact on the office 365 tenant, it did so at a rate of 2 to 3 per second. This would not stop until I made one account different, such as

I changed it to make every account the same as their email. What I didn’t expect what that bob jones in chicago, his logon account might have been chicago\bjones, but his configured email was The administrator ran into a conflict while creating the email account in the Exchange management console (EMC) and unchecked “Use Policy” and gave bob in chicago a non standard email address.

Lessons learned: Set the UPN prefix to the prefix the the default email address, and then set the suffix to

Besides, I have run into places where you may logon as bj9874 and your email is I would think you really want everyone logging in using their email address on office 365 portal, rather then their userid.

It’s worth noting that the prefix of the upn is, by default, is the same as the samaccount name when you setup the account in ADUC or EMC.