How to switch Office 365 licenses using PowerShell

When making changes to licenses in Office 365, I sometimes experience that the old and new licenses include options that conflict, and does not allow the licenses to be pooled or added to accounts at the same time.
Changing the license of users in Office 365 need to be performed without impacting the end users or affecting the services and data they consume.

This situation is ideal for using the Azure AD PowerShell module to perform the license switch.

First, we need to get the old and new license SKU, using the Get-MsolAccountSku cmdlet.

Get-MsolAccountSku

AccountSkuId                      ActiveUnits WarningUnits ConsumedUnits

============                      =========== ============ =============

adatumdk:STREAM                   1000000     0            1

adatumdk:POWER_BI_INDIVIDUAL_USER 100         0            98

adatumdk:ENTERPRISEPACK           150         150          150

adatumdk:POWER_BI_STANDARD        1000000     0            100

adatumdk:MCOMEETADV               25          0            23

adatumdk:O365_BUSINESS_ESSENTIALS 175         0            0

adatumdk:SMB_BUSINESS_ESSENTIALS  175         175          173

adatumdk:MCOSTANDARD              1           0            0

 

Looking in the  Office 365 Portal, you may be surprised to see two seperate licenses, as they have the exact same name (Office 365 Business Essentials), and therefore should be pooled. With PowerShell we can see that they are actually two different licensing SKU ID’s (SKU = Stock Keeping Unit), and this also tells us, that there is difference between the two licenses.
Make a note of the ConsumedUnits count (here 173) of the current assigned licenses, as this will be used during the final verification.

We can drill a step further down in the details of each SKU, using the Get-MsolAccountSku cmdlet:

Details of the SMB_BUSINESS_ESSENTIALS SKU:

 

(Get-MsolAccountSku | where {$_.AccountSkuId -eq adatumdk:SMB_BUSINESS_ESSENTIALS}).ServiceStatus

 

ServicePlan           ProvisioningStatus

===========           ==================
FLOW_O365_P1          Success

POWERAPPS_O365_P1     Success

TEAMS1                Success

PROJECTWORKMANAGEMENT Success

SWAY                  Success

INTUNE_O365           PendingActivation

YAMMER_MIDSIZE        Success

EXCHANGE_S_STANDARD   Success

MCOSTANDARD           Success

SHAREPOINTSTANDARD    Success

SHAREPOINTWAC         Success

 

Details of the O365_BUSINESS_ESSENTIALS SKU:

 

(Get-MsolAccountSku | where {$_.AccountSkuId -eq adatumdk:O365_BUSINESS_ESSENTIALS}).ServiceStatus

 

ServicePlan           ProvisioningStatus

===========           ==================

FLOW_O365_P1          Success

POWERAPPS_O365_P1     Success

TEAMS1                Success

PROJECTWORKMANAGEMENT Success

SWAY                  Success

INTUNE_O365           PendingActivation

SHAREPOINTWAC         Success

YAMMER_ENTERPRISE     Success

EXCHANGE_S_STANDARD   Success

MCOSTANDARD           Success

SHAREPOINTSTANDARD    Success

 

As seen above, the difference between the two licenses are, that the YAMMER_MIDSIZE plan is included in the current SMB_BUSINESS_ESSENTIALS SKU, while the new O365_BUSINESS_ESSENTIALS SKU instead contains the YAMMER_ENTERPRISE plan. Because these plans cannot “co-exist”, we would get an error, if we try to assign both licenses to the same account. This also provides us with an explanation why the two Office 365 Business Essentials licenses are not pooled in the first place.

 

Moving on, get a list of accounts that have the current SMB_BUSINESS_ESSENTIALS license assigned:

 

Get-MsolUser -All | Where {$_.isLicensed -eq “TRUE” -and $_.Licenses.AccountSKUID -eq adatumdk:SMB_BUSINESS_ESSENTIALS} | Select Displayname,UserPrincipalName,isLicensed,Licenses

 

DisplayName           UserPrincipalName    IsLicensed Licenses

===========           =================    ========== ========

John Doe              jdoe@adatum.dk       True       {adatumdk:SMB_BUSINESS_ESSENTIALS}

Nancy Trust           ntr@adatum.dk        True       {adatumdk:SMB_BUSINESS_ESSENTIALS}

Scott Thomas          sct@adatum.dk        True       {adatumdk:SMB_BUSINESS_ESSENTIALS}

Thomas A. Anderson    Neo@adatum.dk        True       {adatumdk:SMB_BUSINESS_ESSENTIALS}

Tom Harrison          toh@adatum.dk        True       {adatumdk:SMB_BUSINESS_ESSENTIALS}

Gwen Schmidt          gws@adatum.dk        True       {adatumdk:SMB_BUSINESS_ESSENTIALS}

 

To switch the two licenses, we can use the Set-MsolUserLicense cmdlet with the AddLicenses and RemoveLicenses options.

 

To change licens assignment for a single account:

 

Set-MsolUserLicense -UserPrincipalName “jdoe@micro-matic.com” –AddLicenses adatumdk:O365_BUSINESS_ESSENTIALSRemoveLicenses adatumdk:SMB_BUSINESS_ESSENTIALS

 

To change the license assignment for all accounts:

 

Get-MsolUser -All | Where {$_.isLicensed -eq “TRUE” -and $_.Licenses.AccountSKUID -eq adatumdk:SMB_BUSINESS_ESSENTIALS} | Set-MsolUserLicenseAddLicenses adatumdk:O365_BUSINESS_ESSENTIALSRemoveLicenses adatumdk:SMB_BUSINESS_ESSENTIALS

 

 

Verify if there are any accounts left with the former  SMB_BUSINESS_ESSENTIALS license assigned – this should provide an empty output:

 

Get-MsolUser -All | Where {$_.isLicensed -eq “TRUE” -and $_.Licenses.AccountSKUID -eq adatumdk:SMB_BUSINESS_ESSENTIALS} | Select Displayname,UserPrincipalName,isLicensed,Licenses

 

 

Get a list of accounts that have the new O365_BUSINESS_ESSENTIALS license assigned:

 

Get-MsolUser -All | Where {$_.isLicensed -eq “TRUE” -and $_.Licenses.AccountSKUID -eq adatumdk:O365_BUSINESS_ESSENTIALS} | Select Displayname,UserPrincipalName,isLicensed,Licenses

 

DisplayName           UserPrincipalName    IsLicensed Licenses

===========           =================    ========== ========

John Doe              jdoe@adatum.dk       True       {adatumdk:O365_BUSINESS_ESSENTIALS}

Nancy Trust           ntr@adatum.dk        True       {adatumdk:O365_BUSINESS_ESSENTIALS}

Scott Thomas          sct@adatum.dk        True       {adatumdk:O365_BUSINESS_ESSENTIALS}

Thomas A. Anderson    Neo@adatum.dk        True       {adatumdk:O365_BUSINESS_ESSENTIALS}

Tom Harrison          toh@adatum.dk        True       {adatumdk:O365_BUSINESS_ESSENTIALS}

Gwen Schmidt          gws@adatum.dk        True       {adatumdk:O365_BUSINESS_ESSENTIALS}

Last, using the Get-MsolAccountSku cmdlet, we can verify that the ConsumedUnits count of the new licenses match the count of the former licenses (in this example 173).

 

Get-MsolAccountSku

 

AccountSkuId                      ActiveUnits WarningUnits ConsumedUnits

============                      =========== ============ =============

adatumdk:STREAM                   1000000     0            1

adatumdk:POWER_BI_INDIVIDUAL_USER 100         0            98

adatumdk:ENTERPRISEPACK           150         150          150

adatumdk:POWER_BI_STANDARD        1000000     0            100

adatumdk:MCOMEETADV               25          0            23

adatumdk:O365_BUSINESS_ESSENTIALS 175         0            173

adatumdk:SMB_BUSINESS_ESSENTIALS  175         175          0

adatumdk:MCOSTANDARD              1           0            0

 

All accounts have now changed their Office 365 license, without affecting the end users or their data.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.