Great post, I have used the following script to collect W10 activation information from over 6000 devices.
$COMPUTER=Get-CimInstance Win32_Computersystem
$BIOS=Get-CimInstance Win32_BIOS
$SLP=Get-CimInstance SoftwareLicensingProduct -Filter "Name like 'Windows%'" | where { $_.PartialProductKey }
$SLS=Get-CimInstance SoftwareLicensingService
$theThingIActuallyWant = New-Object psobject -Property @{
SystemName = $COMPUTER.Name
Manufacturer = $COMPUTER.manufacturer
Model=$COMPUTER.Model
SystemSKUNumber=$COMPUTER.SystemSKUNumber
Serialnumber=$BIOS.SerialNumber
ProductKeyChannel=$SLP.ProductKeyChannel
LicenseFamily=$SLP.LicenseFamily
PartialProductKey=$SLP.PartialProductKey
LicenseStatus=$SLP.LicenseStatus
OA3xOriginalProductKey=$SLS.OA3xOriginalProductKey
}
$theThingIActuallyWant | ConvertTo-Json -Compress
When I query the Graph Explorer I get the correct output, but I cannot convert back to json using the command convertfrom-json.
I receive the following error message:
At line:1 char:38
+ $objResultMessage = $resultMessage | ConvertFrom-Json
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [ConvertFrom-Json], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.ConvertFromJsonCommand