Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mozziemozz/174b665e5aa94cbd3c1421665032cbb0 to your computer and use it in GitHub Desktop.
Save mozziemozz/174b665e5aa94cbd3c1421665032cbb0 to your computer and use it in GitHub Desktop.
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)][String]$TenantId,
[Parameter(Mandatory=$true)][String]$AppId,
[Parameter(Mandatory=$true)][String]$AppSecret
)
Invoke-Expression (Invoke-RestMethod -Method Get -Uri "https://raw.githubusercontent.com/mozziemozz/TeamsPhoneAutomation/main/Functions/Connect-MgGraphHTTP.ps1")
. Connect-MgGraphHTTP -TenantId $TenantId -AppId $AppId -AppSecret $AppSecret
$licenseSkus = Invoke-RestMethod -Method Get -Headers $Header -Uri "https://graph.microsoft.com/v1.0/subscribedSkus"
$translationTable = Invoke-RestMethod -Method Get -Uri "https://download.microsoft.com/download/e/3/e/e3e9faf2-f28b-490a-9ada-c6089a1fc5b0/Product%20names%20and%20service%20plan%20identifiers%20for%20licensing.csv" | ConvertFrom-Csv
$output = @()
foreach ($sku in $licenseSkus.value) {
$skuDetails = New-Object -TypeName psobject
$skuNamePretty = ($translationTable | Where-Object {$_.GUID -eq $sku.skuId} | Sort-Object Product_Display_Name -Unique).Product_Display_Name
$skuDetails | Add-Member -MemberType NoteProperty -Name "LicenseName" -Value $skuNamePretty
$skuDetails | Add-Member -MemberType NoteProperty -Name "StringId" -Value $sku.skuPartNumber
$skuDetails | Add-Member -MemberType NoteProperty -Name "LicenseId" -Value $sku.skuId
$output += $skuDetails
}
$output | Where-Object {$_.LicenseName -ne $null} | Out-GridView -Title "License Names"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment