Assigning Office 365 Licensing in PowerShell


As part of my dive into automating as much as possible of a Microsoft Teams implementation or migration from Skype for Business On-Premise, I am focusing on scripting as much as possible.

This post focuses on the licensing element. You are unable to enable users in Teams unless they have the correct licenses already assigned. The following commands will allow us to check what licensing is available to the tenant.

To check this you must first connect to the Microsoft Online Service.

Run: Connect-MsolService

You will be prompted for your O365 credentials and any MFA (you have MFA enabled right...)

Now run: Get-MsolAccountSku

You will see the output on the screen of the different licenses on the tenant:


In the output the first element before the license type we have the tenant name XXXXX: followed by the License type and how many units of each, warnings and ConsumedUnits (Assigned Licenses)

This ties in with what we see in the GUI in Office 365 Admin Center:


These are many options, above shows just one customer example in the education industry, a breakdown of all of the options are available here.

Some sample common licenses are as follows:

Product name String ID
AUDIO CONFERENCING MCOMEETADV
AZURE ACTIVE DIRECTORY BASIC AAD_BASIC
AZURE ACTIVE DIRECTORY PREMIUM P1 AAD_PREMIUM
AZURE ACTIVE DIRECTORY PREMIUM P2 AAD_PREMIUM_P2
ENTERPRISE MOBILITY + SECURITY E3 EMS
ENTERPRISE MOBILITY + SECURITY E5 EMSPREMIUM
EXCHANGE ONLINE (PLAN 1) EXCHANGESTANDARD
EXCHANGE ONLINE (PLAN 2) EXCHANGEENTERPRISE
INTUNE INTUNE_A
MICROSOFT 365 BUSINESS SPB
MICROSOFT 365 E3 SPE_E3
OFFICE 365 BUSINESS O365_BUSINESS
OFFICE 365 BUSINESS SMB_BUSINESS
OFFICE 365 BUSINESS ESSENTIALS O365_BUSINESS_ESSENTIALS
OFFICE 365 BUSINESS ESSENTIALS SMB_BUSINESS_ESSENTIALS
OFFICE 365 BUSINESS PREMIUM O365_BUSINESS_PREMIUM
OFFICE 365 BUSINESS PREMIUM SMB_BUSINESS_PREMIUM
OFFICE 365 ENTERPRISE E1 STANDARDPACK
OFFICE 365 ENTERPRISE E2 STANDARDWOFFPACK
OFFICE 365 ENTERPRISE E3 ENTERPRISEPACK
OFFICE 365 ENTERPRISE E3 DEVELOPER DEVELOPERPACK
OFFICE 365 ENTERPRISE E4 ENTERPRISEWITHSCAL
OFFICE 365 ENTERPRISE E5 ENTERPRISEPREMIUM
OFFICE 365 ENTERPRISE E5 WITHOUT AUDIO CONFERENCING ENTERPRISEPREMIUM_NOPSTNCONF
OFFICE 365 F1 DESKLESSPACK
OFFICE 365 MIDSIZE BUSINESS MIDSIZEPACK
OFFICE 365 PROPLUS OFFICESUBSCRIPTION
OFFICE 365 SMALL BUSINESS LITEPACK
OFFICE 365 SMALL BUSINESS PREMIUM LITEPACK_P2
SKYPE FOR BUSINESS CLOUD PBX
This is also Teams Phone System Add On
MCOEV
SKYPE FOR BUSINESS ONLINE (PLAN 1) MCOIMP
SKYPE FOR BUSINESS ONLINE (PLAN 2) MCOSTANDARD
SKYPE FOR BUSINESS PSTN CONFERENCING MCOMEETADV
SKYPE FOR BUSINESS PSTN DOMESTIC AND INTERNATIONAL CALLING MCOPSTN2
SKYPE FOR BUSINESS PSTN DOMESTIC CALLING MCOPSTN1
SKYPE FOR BUSINESS PSTN DOMESTIC CALLING (120 Minutes) MCOPSTN5
WINDOWS 10 ENTERPRISE E3 WIN10_PRO_ENT_SUB


Now we know the license codes, we can script the assignment of the licenses to the users, we can bundle this in a larger script for enabling users for Teams and assigning policies, this blog post will follow in the coming days, I will use variables for individual user migration and for bulk migration using populated CSV files.

To check what licenses are currently assigned to the user:

Get-MsolUser -UserPrincipalName "martin.gibney@martingibney.com" | select licenses




Now to set the license against the user:

Set-MsolUserLicense -UserPrincipalName "matin.gibney@martingibney.com" -AddLicenses "tenantname:MCOEV"

Ensure you are connected to MSOL when you run this command or it will not work. There are also licenses you cannot combine, these are shown in the earlier link.

I hope this post was useful to you.

Comments

Popular posts from this blog

Teams Device Health Monitoring and Reporting

Unassigned Numbers in Microsoft Teams using Audiocodes SBC

SIP port on Checkpoint firewalls