Office 365 PowerShell – Part 1

Lately, we have been doing a lot of migrations to Office 365. That’s why I decided to post a series of articles on the topic of managing our Office 365 environment using PowerShell scripts. To do this, we must approach each of the services a bit differently and it also requires some preparation, like additional software.

Preparation

To connect to Office 365, we first need to install some additional software.

Microsoft Online Services Sign-In Assistant

You can find the Microsoft Online Services Sign-In Assistant at the following link:

https://www.microsoft.com/en-us/download/details.aspx?id=41950

Microsoft Online services Sign-in Assistant is a tool that enables us to sign in to Microsoft Online services. The tool isn’t meant for a »Single sign-on« experience for corporations, it just enables us to sign in to Microsoft services in the cloud.

Azure Active Directory Connect

Azure Active Directory Connect is a piece of software that installs all the commands we need to connect to Microsoft Online services. Because of this, all commands have the prefix of “MSOL”. After installing it, we can list all commands in PowerShell by using the following command:

Get-Command -Noun "msol*"

The tool is available at the following link:

https://www.microsoft.com/en-us/download/details.aspx?id=47594

Azure Active Directory PowerShell

Microsoft Online Services Sign-In Assistant is just a piece of software, that knows how to authenticate users to cloud services, but it doesn’t provide any actual management capabilities. By installing Azure Active Directory PowerShell, our PowerShell environment gets the commandlets (cmdlets) we need to perform operations on our Azure AD. Installing this add-on is very simple and can be done through PowerShell. To do this, we mucst be using at least PowerShell v5 and run PowerShell as an administrator. Then, we use the following command:

Install-Module AzureAD

The command fetches the necessary components from PowerShell Gallery and installs new commands that we can use to managae Azure AD settings.

Connecting to Office 365 Services

By installing the above-mentioned add-ins, we can now successfully connect to Office 365 and Azure AD. To check if everything is working and to acquaint ourselves with the MS Online commands, we can run the following command in our PowerShell environment.

Connect-MsolService -Credential (Get-Credential)

The command line requires us to enter our username and password. If PowerShell has successfully connected to cloud services, all that is returned is an empty line. No confirmation of a successful sign-in is shown.

To check if we actually receive information about our subscription, we can run the following command:

Get-MsolDomain 

This should give us a list of all domains registered in our tenant.

This concludes the first part in our series of articles. Be sure to check out part 2, which deals with managing Skype for Business online.

Leave a Reply

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