Adding multiple mailboxes to your Office 365 organization or repeatedly changing the setting on several accounts...
is monotonous and a waste of time. Instead of clicking around in the GUI, use PowerShell.
PowerShell in Exchange creates mailboxes, changes message routing, migrates on-premises to Office 365 and finds and manages messages across servers. For example, importing a PowerShell module into your console allows you to create simple scripts for a few mailboxes to detail orchestrations for new employee provisioning.
Performing actions in Office 365 via PowerShell is a little different than using the graphical user interface (GUI). However, if you learn a few steps on connecting, you can save time with Office 365 administration.
This article is based on using a Windows 8.1 computer with PowerShell version 4 -- but you can manage Office 365 with PowerShell using Windows 7. If you're still on XP, you won't be able to connect Office 365 via PowerShell because you need at least PowerShell version 3.
Initial module setup
First, install the Microsoft Online Services Sign-In Assistant -- the 64-bit version if you're on an x64 OS. Always use the x64 version on a Windows x64 OS; if you're on another OS, you have to use the x86 version. Accept the EULA and accept the defaults.
Next, install the Windows Azure Active Directory Module for PowerShell. As with any additional functionality in PowerShell, you need to install a module. Use an Azure module rather than an Office 365 module, because Office 365 is built on Azure. Microsoft is continually bringing its cloud services under the Azure umbrella.
The installation is just as easy as it was for the Sign-In Assistant -- simply accept all defaults.
Resources for PowerShell newbies
PowerShell is capable of managing and automating many more technologies other than Office 365. Conduct an Internet search on PowerShell and another technology and you'll find a lot of information.
The Azure Active Directory Module installation creates a program group for you. This is one option to connect to Office 365 with PowerShell. If you do more than just manage Office 365, you probably already have your own way of launching the PowerShell console.
To use an existing PowerShell console, verify MSOnline module is available. If your install was successful, you should see something similar to what's shown in Figure 1; proceed to connecting to Office 365 via PowerShell. If you do not see this, reinstall the module.
Connect Office 365 via PowerShell
Use the Connect-MsolService cmdlet to initiate a connection with Windows Azure Active Directory -- the authentication service for Office 365.
Type Connect-MsolService with no parameters and enter a username and password (Figure 2) when prompted. Use a basic admin account, although Microsoft recommends being a global admin to prevent any permission problems.
Once you input your Office 365 credentials, you should have a connection.
Managing Office 365 with PowerShell
When learning a new PowerShell module, check what cmdlets are available. Use the Get-Command (Figure 3) with the -Module parameter, which allows you to see the available commands.
Test some of the Get commands first, like Get-MsolUser, to find all of your user accounts -- or type Get-Msol and hit the tab key to see the PowerShell cycles through all of the available commands.
If you're unfamiliar with a particular command, the Get-Help command, or help (figure 4), will present further information about it. For example, if you don't know what the Get-MsolAdministrativeUnit cmdlet does, type help Get-MsolAdminsitrativeUnit to see more information.
Keep your PowerShell session open to use all of the available cmdlets. Once you close the session, you must reconnect with Connect-MsolService.
Connect to Office 365's PowerShell in the cloud
New Office 365 connection with ExpressRoute
Hybrid Office 365: PowerShell commands for single sign-on
Office 365 authentication via PowerShell