The Get-MgSubscribedSku
Graph cmdlet can give a list of all the licensing SKUs subscribed in your tenant. Here’s an example output:
1 2 3 4 5 6 7 8 9 10 11 |
❯ (Get-MgSubscribedSku)[0] | fl * AppliesTo : User CapabilityStatus : Enabled ConsumedUnits : 240 Id : 3c49b111-19db-458d-83ff-1af0ac9ae35b_c5928f49-12ba-48f7-ada3-0d743a3601d5 PrepaidUnits : Microsoft.Graph.PowerShell.Models.MicrosoftGraphLicenseUnitsDetail ServicePlans : {ONEDRIVE_BASIC, VISIOONLINE, EXCHANGE_S_FOUNDATION, VISIO_CLIENT_SUBSCRIPTION} SkuId : c5928f49-12ba-48f7-ada3-0d743a3601d5 SkuPartNumber : VISIOCLIENT AdditionalProperties : {} |
The problem is it doesn’t have the friendly display name. So in my scripts, for instance, if want to get the SKU Id of “VISIO ONLINE PLAN 2” I have to lookup this Microsoft doc to find that the SKU PartNumber for that is “VISIOCLIENT” and then either use the Id from that document itself or search for “VISIOCLIENT” in Get-MgSubscribedSku
and get the Id from there. That’s not ideal.
The document refers to a CSV file (https://download.microsoft.com/download/e/3/e/e3e9faf2-f28b-490a-9ada-c6089a1fc5b0/Product%20names%20and%20service%20plan%20identifiers%20for%20licensing.csv) that is updated regularly and has the friendly display name to SKU PartNumber and Id mappings in it. I figured its easy to just pull this document and get the mappings directly:
1 2 3 4 5 6 7 8 9 10 |
$licenseCsvURL = 'https://download.microsoft.com/download/e/3/e/e3e9faf2-f28b-490a-9ada-c6089a1fc5b0/Product%20names%20and%20service%20plan%20identifiers%20for%20licensing.csv' $licenseHashTable = @{} (Invoke-WebRequest -Uri $licenseCsvURL).ToString() | ConvertFrom-Csv | ForEach-Object { $licenseHashTable[$_.Product_Display_Name] = @{ "SkuId" = $_.GUID "SkuPartNumber" = $_.String_Id "DisplayName" = $_.Product_Display_Name } } |
Now if I want to search for “Office 365 E3” I can do the following:
1 2 3 4 5 6 7 |
❯ $licenseHashTable["Office 365 E3"] Name Value ---- ----- SkuPartNumber ENTERPRISEPACK DisplayName Office 365 E3 SkuId 6fd2c87f-b296-42f0-b197-1e91e994b900 |
It’s a stupid little thing but at least I don’t have to hard code info in my script any more! :)
Hopefully the link is static and doesn’t change and break stuff lol.