Erwin Bierens

Knowledge is Power

Microsoft 365 - Assign licenses with PowerShell to users

2022-11-28 2 min read Microsoft365

During the working week i get a lot of questions about assigning licenses (mostly the Microsoft Teams Phone Standard license) to users in bulk. This can be easily resolved with PowerShell.

First logon to MSOnline, if you don’t have this module installed use: Install-Module -name MSOnline


Let’s see your active licenses


In order to assign a license to one of your users use the following cmdlet

Set-MsolUserLicense -UserPrincipalName -AddLicenses tenant:mcoev

In this example we’ve assigned the Microsoft Teams Phone Standard license to the user.

Bulk mode

If you want to do this for multiple accounts you can do this by creating a script. First create a csv file with a column header: UPN List all accounts below with the UPN address who will need the license.

Save script below as Set-SKULicense.ps1 and change the $FilePath to the correct filename. Now just run the file and copy/paste the license in the prompt you want to assign.

$FilePath = "c:\temp\users.csv"

Import-Module MSOnline

#list all available SKUs
Get-MsolAccountSku | ft AccountSkuId

Write-Host -ForegroundColor Cyan "[OK] waiting for 10 seconds"
Start-Sleep 10

Write-Host -ForegroundColor Cyan "Please provide the right tenant:sku from above list"
$LicenseSKU = Read-Host "Please enter tenant:sku"

#import the CSV file
Import-Csv $FilePath | ForEach-Object {
        Set-MsolUserLicense -UserPrincipalName $_.UPN -AddLicenses $LicenseSKU
        Write-Host "License $LicenseSKU assigned to "$($_.UPN)"" -ForegroundColor Green

    catch {
        Write-Host "[ERROR] License not assigned to user "$($_.UPN)"" -ForegroundColor Red 

# disconnect session
comments powered by Disqus