Adventures in Office 365 PowerShell

I’ve been pretty busy over the past few months and one of the engagements I had, was to automate a set of Office 365 migrations for a customer using PowerShell.

The engagement started off with a design workshop led by a colleague James Brewster. Corey Goodchild, Joe Majoros and myself worked with the customer to establish what the script needed to do and how it was supposed to do this.

The customer had the following criteria:

  • The user must be running Office 365 ProPlus / Office 2016.
  • The user must not be set with a non-expiring password.
  • The user must have logged in within the past 30 days and have changed their password in the past 100 days.
  • The user’s principal name should match their email address.
  • The process should automate the migration.
  • The process should automate the switchover of Skype for Business from the existing hosted solution.
  • The process should automate the activation of OneDrive for Business and copy the user’s data.

So with these in mind, the four of us developed several scripts that would accomplish the tasks without user intervention.

  • Joe created a PowerShell script that would run as part of the logon script to identify if OneDrive was actively syncing and activate it if it wasn’t, then to move the My Documents folder to the OneDrive local copy.
  • Corey created a PowerShell script (that he later rewrote into VBscript) that would run as part of the logon script to identify the version of Office installed and write that version number into a custom AD attribute.
  • Corey created a second PowerShell script to be run as part of the logon script to remove the existing IM profile. This would cause the client to use AutoDiscover to find the new Skype for Business solution and connect to that.
  • I created a large PowerShell script to automate the Office 365 migrations with minimal intervention from the customer.

The scripts have been used by the customer and have been responsible for migrating over 2000 user mailboxes. The migration script has been refined with robust error-checking, and will make an appearance in future migration engagements.

Post to Twitter

Leave a Comment

Your email address will not be published. Required fields are marked *