In my earlier article on Office 365 and PowerShell, I explained broadly how PowerShell might be of use in managing your Office 365 subscription. As I explained, you can use PowerShell to manage both your Office 365 subscription and the Exchange part of that subscription. In this article, I will look at how you can use PowerShell to manage your Office 365 subscription.
Managing Office 365
Office 365 is not really a single service with a single administrative interface. You need to manage the service itself, and the key components (Exchange Online, Lync Online and SharePoint Online) separately using different tools. You can use the Admin portal, shown below, for most of the administrative task - the web interface hides the fact that the service is made up of several independent pieces.
Managing Services with PowerShell While administering your subscription using the web portal is straightforward, automation is often appropriate. And for automation on the Windows platform, you need PowerShell.
PowerShell is an amazingly rich product and offers you different ways of managing systems. The two main approaches are:
Both of these approaches enable you to run local scripts that invoke the cmdlets/Proxy Functions and to manage application suites from your local machine. Thus you have the opportunity to sit in your nice comfy chair and listen to an old Grateful Dead concert on the web, while administering at least part of Office 365. Bliss!
The Microsoft Online Services Cmdlets
Microsoft has published a set of cmdlets that you can use to administer the Office 365 service - these are available in both 32-bit or 64-bit versions (you pick the version dependant on your OS). To run these cmdlets, you need to install them on Windows 7 (or Windows Server 2008 R2) or higher. Additionally, before installing the Cmdlets, you need to have downloaded and installed the Microsoft Online Services Assistant (which is also a 32-bit or 64-bit install). You can get both of these packages in the necessary format from the Microsoft help website.
Both items are downloaded as .MSI packages - running them and just clicking Next is all it takes to install them. After you install the cmdlets, you have two new modules: MSOnline and MSOnlineExtended. I'm not sure why Microsoft decided to create two modules when just one would have sufficed - but that's what it did.
To use the cmdlets, you first need to import the cmdlets into your PowerShell session and log in to the Office 365 service using the Connect-MsolService, which must specify a credential object holding your Office 365 credentials, like this:
$O365Cred = Get-Credential administrator@MyO365.OnMicrosoft.Com
Connect-MsolService -Credential $cred365
Once you run these two cmdlets, you can access the over 60 cmdlets in the two modules. If you are using Windows 8 as your client (or running a beta of Powershell V3), PowerShell automatically loads modules as you use cmdlets, so there is no reason to explicitly use Import-Module to load the two PowerShell modules. Of course, if you are any sort of self respecting geek, you will have already loaded the beta of PowerShell V3 and have seen this. But PowerShell V3 is a story for another time.
Using the MS Online PowerShell Modules
The MS Online PowerShell modules are comprehensive in terms of managing the basic Office 365 service. These cmdlets enable you to manage:
To describe all these fully would require an entire book, or at least several chapters. If you are an IT Pro, particularly an IT Pro at a Microsoft Partner, why not sign up for a 29-day trial account and experiment with PowerShell and Office 365? So far as I can tell, there is no limit to the number of trial versions you can sign up for - if you are careful, you can just create new accounts each month to continue your learning!
Here is a simple script to get some basic information from Office 365 using the cmdlets, illustrated using the PowerShell ISE:
In this example I connect to the Office 365 service and then get details of my subscription and of all the (one!) users in my subscription. These cmdlets are, like all PowerShell cmdlets, pretty easy to use. And since its PowerShell - you can use the Get-Help cmdlet to get help about each of the MSOnline Cmdlets. Sadly, the OnLine parameter of Get-Help does not work at present, but the in-box help is good. Perhaps online help is something for the next release?
So Why Use PowerShell to Manage Office 365? For many small firms without IT skills taking advantage of the Small Business plans, managing their Office 365 accounts, licenses, etc. is probably best done via the portal interface.
For larger Office 365 accounts, or for any account with a PowerShell savvy administrator, using PowerShell is the obvious choice. PowerShell's major benefit of reliable, repeatable automation makes it the tool of choice. While changing one or two settings via the web interface is simple, can you imagine having to change hundreds of passwords without PowerShell or provisioning a thousand new users from the Web Interface? Add to that the ability to audit what was done, when and by whom - this makes PowerShell an important tool for managing larger Office 365 accounts.
Managing Office 365 using PowerShell is pretty easy - download and install a couple of tools and away you go. PowerShell offers a number of key benefits, particularly reliable and repeatable automation of administrative tasks.
In the next article, I'll take a look at how you can manage the Exchange Online component of Office 365 using PowerShell and PowerShell Remoting.