Office 365 License Automation Part 1

Hey Guys,

I am currently working on some automated PowerShell scripts to license Office 365 users, however licensing Office 365 users isn’t enough for me, I want to be able to build profiles for different types of users and turn off certain services for those users. The first script will be everything on, and then maybe everything but skype on, and so on and so forth. This will help me in the long run not give too many options to users thus overwhelming them and discouraging their use of Office 365 features.

Currently when adding a user or two, I am going into the Admin center and selecting a user and licensing them. This helps me understand what services are available to me. When I select a user, and expand Office 365 Enterprise E4 (yes it’s a no longer available plan) I see

In PowerShell, however the naming conventions are different, so in order to build out my profiles I am going to build a matrix of different types of users here with different options turned on and off. My first step though since this is going to be done through PowerShell is to reconcile these names with what their called in PowerShell.

The first step is to Connect to MSOLService. We will want to identify what Account Sku’s are available to us.

for this you’ll run Get-MsolAccountSku

This will show you all of the account sku’s that you have available. You’ll notice that you will often have multiple sku’s available to you which you can reconcile with, they are not necessarily in order but it’s easier to run elimination on a much smaller list when compared to the services list.

It’s the services list that I want to reconcile to figure out what services I need to identity to start building my licensing matrix. I’ve identified which AccountSkuID I need to work with, one way to do this is to look at the ActiveUnits, they should equal the number of licenses that you have on that Sku ID. Once you’ve identifed that you need to request all of the ServiceStatus’ within that AccountSkuID. To do that we will use the following cmdlet

(Get-MsolAccountSku | where {$_.AccountSkuId -eq ‘cmamdm:ENTERPRISEWITHSCAL’}).ServiceStatus

I get all of the services associated to my main Sku ID, and then I have to simply match the service listed here to the service in licensing.

When matched up, I get the following picture which will help me build my matrix.

Now I can continue building out my scripts.




  1. Nice, i have built some scripts to provision new users. Generally E3’s though. I made a cludegy asp page for hr to put the user requests with a backend mssql db(wish we had a web dev resource) . Then we just complete-userrequest -id xyz.

    We are running dirsync though. You guys adfs?

    • We do everything wit ADUC and powershell scripts…to create users we allow the SD to run the scripts enter the variables and the PowerShell scripts do the rest. A webpage my do the trick though…

      We have ADFS and AD connect (newer version of Dir Sync)

  2. I must say you have very interesting articles here.
    Your blog should go viral. You need initial traffic only.
    How to get it? Search for; Miftolo’s tools go viral

Leave a comment

Your email address will not be published.