The Basics

Recently I’ve had to explore the dark art of license assignment using Powershell. It’s not particularly well documented so this might help you…

Displaying a list of the current licensing assignment is pretty straightforward. Get-MsolUser can be used to return information on an individual or a list of users.

Get-MsolUser -All run on its own will return all of the users available in the tenant along with whether or not there is a user license assigned.

To make this a bit more usable, you could pipe this output to a CSV file and work with it from there

Get-MsolUser | Export-Csv c:\path\AllUsers.CSV

If you want to filter it a bit more you can user the “TRUE” or “FALSE” options

Get-MsolUser | Where-Object {$_.isLicensed -eq “TRUE”} | Export-Csv c:\path\AllUsersWithLicenses.CSV

First Time License Assignment

The next step from here is to know what licensing SKU you have available before you can apply it. The first thing you will need to do is obtain the AccountSkuId values that have been setup for your tenant.

In my case, I have an E3 tenant which is an ENTERPRISEPACK AccountSkuId that is prefixed with the name of my tenant. You need to display your SKU:

Get-MsolAccountSku | Format-Table AccountSkuId, SkuPartNumber

If you have an E4 subscription, the AccountSkuId is ENTERPRISEPACKWITHCAL

The available service plans in each of these are

  • OFFICESUBSCRIPTION (Office Pro Plus)
  • MCOSTANDARD (Lync Online)
  • SHAREPOINTWAC (Office Web Apps)
  • SHAREPOINTENTERPRISE (Sharepoint Online)
  • EXCHANGE_S_ENTERPRISE (Exchange Online)

In the Kiosk plans the AccountSkuId is DESKLESSWOFFPACK and this contains:

  • SHAREPOINTWAC
  • SHAREPOINTDESKLESS
  • EXCHANGE_S_DESKLESS

The Exchange Online Archiving SKU contains:

  • EXCHANGE_S_ARCHIVE

Doing bulk license assignments you’ll need to create a CSV file containing the UPN for each batch you want to license. I’ve names the column in my CSV “UPN”

Then you’ll need to set the licenses you would like to disable, in my example I only want to assign a license for Office Pro Plus so I need to set a variable which contains my assignment:

$Step1 = New-MsolLicenseOptions -AccountSkuId klouds:ENTERPRISEPACK -DisabledPlans MCOSTANDARD,SHAREPOINTWAC,SHAREPOINTENTERPRISE,EXCHANGE_S_ENTERPRISE

When assigning a license for the first time you also need to specify the country of use

Import-Csv .\Sample.CSV | foreach {set-MsolUser -UserPrincipalName $_.UPN -UsageLocation AU}

The next step is to assign the license:

Import-Csv .\Sample.CSV | foreach {Set-MsolUserLicense -UserPrincipalName $_.UPN -AddLicenses klouds:ENTERPRISEPACK -verbose -LicenseOptions $Step1}

You can check the license assignment with:

(Get-MSOLUser –UserPrincipalName “Your UPN”).Licenses[0].ServiceStatus

Modifying Subscriptions within a License

As with the first time license assignment, you will need to set a variable containing the license subscriptions you want to activate. In my example I am going to remove the Office Pro Plus subscription and activate Exchange Online:

$Step2 = New-MsolLicenseOptions -AccountSkuId klouds:ENTERPRISEPACK -DisabledPlans OFFICESUBSCRIPTION,MCOSTANDARD,SHAREPOINTWAC,SHAREPOINTENTERPRISE

The next step is to assign remove the Office Pro Plus subscription and assign Exchange Online

Import-Csv .\Sample.CSV | ForEach {Set-MsolUserLicense -UserPrincipalName $_.UPN -LicenseOptions $Step2}

Again using (Get-MSOLUser –UserPrincipalName “Your UPN”).Licenses[0].ServiceStatus you can see that the change to the subscription was successful:

If you try to modify the subscription using the same commands used for first time license allocation, you will get an error stating that the license is invalid

Category:
Office 365
Tags:
,

Join the conversation! 8 Comments

  1. Can you please put a sample of the Sample.csv file up.

    Thank You!

  2. Particularly decent post Office 365 Licensing with Powershell « Kloud Blog.. Carry on writing!

    !

  3. Hi mate,

    How can I assign, for example, Exchange Online to a big batch of users who will undoubtedly be in a different state to one another, i.e., some may be SharePoint users, others Lynch etc.

    How could I enable all of them for Exchange Online without breaking their SharePoint and/or Lynch access, and also without giving all of them SharePoint and Lynch access in a band-aid style solution?

    Cheers mate!

  4. Do you know if it is possible to get the number of licenses used for a specific subscription? I am looking to a way to get the “stats” of a subscrtipion. With Get-MsolSubscription I can find the total number of seats included in the subscription, but not how many are used.

  5. Check licence status one-liner.

    ((get-msoluser -userprincipalname “UPN@UPN.com”).Licenses[0].ServiceStatus | ? {$_.ServicePlan.ServiceName -match “EXCHANGE”}).ProvisioningStatus

  6. This is great! Saved countless hours! thank you sooooo much!!

  7. Hi! I want to show a list of all users in an department. That’s not the problem 🙂 But the second column is harder to show. I need the information, if Exchange Online is activated. Can you help, please?

Comments are closed.