Office 365 licensing (using PowerShell)

Below are some very simple powershell code to handle licensing in Office 365:

# Powershell
# Requirement: Connected to msol-service


# Get your SKU, extract your AccountSkuId (tenantname:SKU)
Get-MsolAccountSku


# Remove license VISIOCLIENT for all users
$all       = get-msoluser -all
$sku       = "mytenant:VISIONCLIENT"
$all | Where-Object {($_.licenses).AccountSkuId -match $sku } | Set-MsolUserLicense -RemoveLicenses $sku


# Add FULL SKU
$all       = get-msoluser -all
$sku       = "mytenant:VISIONCLIENT"
$all | Set-MsolUserLicense -AddLicenses $sku


# Add PARTIAL SKU (SKU: F1, disable FLOW and Teams)
$SKU       = "mytenant:DESKLESSPACK"
$options   = New-MsolLicenseOptions -AccountSkuId mytenant:DESKLESSPACK -DisabledPlans FLOW_O365_S1,TEAMS1
$all | Set-MsolUserLicense -AddLicenses $SKU -LicenseOptions $options

No comments: