Extract M365 Licensing GUID's and Product names from MS Website

Hi All,

For a Project i wanted to Extract the M365 License and ServicePlan Guids from the Website below

Product names and service plan identifiers for licensing


The whole Script is published at my GitHub Repo

Why not using PowerShell for that

$URI = "https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-service-plan-reference"
$WebRequest = Invoke-WebRequest -URI $URI
$WebRequest | get-member


As you can see, with PowerShell 7 the Property "ParsedHtml" is missing. It somehow has a dependency to the local installed Browser. So you can't use it on Azure Automation :(

$URI = "https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-service-plan-reference"
$WebRequest = Invoke-WebRequest -URI $URI
$WebRequest | get-member


You can get the same behavior, wen using the UseBasicParsing Parameter.

$URI = "https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-service-plan-reference"
$WebRequest = Invoke-WebRequest -URI $URI -UseBasicParsing
$WebRequest | get-member


I found this Function to convert a HTML Table - but it relies on that ParsedHtml Attribute


$tables = @($WebRequest.ParsedHtml.getElementsByTagName("TABLE"))
$table = $tables[0]
$MSServicePlan = ConvertFrom-HTMLTable $table
$MSServicePlan[0]


$MSServicePlan | ft "GUID","String ID","Product Name"


$MSServicePlan |  Export-CSV -Path "C:\Temp\licensing-service-plan.csv" -Encoding UTF8 -NoTypeInformation



Regards
Andres Bohren