Jun 21

Getting started with Office 365 and PowerShell

Before trying to use PowerShell with Office 365 certain libraries need to be installed on the client machine, these libraries are dependent on OS, for Windows 7 additional libraries are required before proceeding.

 

OS Required libraries
Windows 7; Windows 7 SP1 Windows Management Framework;
Microsoft Online Services Sign-In Assistant for IT Professionals RTW;
Windows Azure Active Directory Module for Windows PowerShell.
Windows 8.1; Windows 10 Microsoft Online Services Sign-In Assistant for IT Professionals RTW;
Windows Azure Active Directory Module for Windows PowerShell.

If you are using Windows 10 you will most likely receive the following error:

“In order to install Windows Azure Active Directory Module for Windows PowerShell, you must have Microsoft Online Services Sign-In Assistant version 7.0 or greater installed on this computer”

If this happens you should make the following changes to your registry using Regedit:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSOIdentityCRL]
 "MSOIDCRLVersion"="7.250.4551.0"
 "MSOIDCRLVersion_Default"="7.250.4303.0"

REMEMBER – Changing your Registry can seriously damage the health of your PC, if you are not comfortable using the tool, find someone who is.

To download these libraries using the following links:

Windows Management Framework

Microsoft Online Services Sign-In Assistant for IT Professionals RTW

Windows Azure Active Directory Module for Windows PowerShell

Once these libraries are installed (in this order) you are ready to start using PowerShell to manipulate your Office 365 tenancy.

Connecting to your tenancy

Before using Powershell with Office 365 you need to connect to your tenancy;

Open your “Windows Azure Active Directory Module for Windows PowerShell” application from your desktop and enter the following command line:

Connect-MSolService

You will be prompted for a login, here you need to enter the details you use to access your tenancy.

First Powershell cmdlet

The first powershell cmdlet I used was to retrieve a list of users:

Get-MsolUser

Will produce a list of current users on your Office 365 tenancy:

Get-MsolUserThis gives you the users principal name, their display name and their current licensed status.

And so it begins, the first steps in Powershell and Office 365.