I’m trying to figure out how to get the information from all of our machines using Powershell to import into AutoPilot.
I think I’ve got most of it working, but the commands I have found using Powershell do not work as expected when pulling the Product ID. We have a mix of the different types of keys, so I’m wondering if that is it. If I use the command (Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey I get the following:
Get-WmiObject : A positional parameter cannot be found that accepts argument ‘*’.
I can use the command line and pull that info, but how do I get it into the variable?
Get system information
$serialNumber = Get-WmiObject win32_bios | Select-Object -ExpandProperty SerialNumber
$productId = wmic path softwarelicensingservice get OA3xOriginalProductKey
$hardwareHash = Get-WmiObject -Class “Win32_ComputerSystemProduct” | Select-Object -ExpandProperty UUID
$model = Get-WmiObject -Class “Win32_ComputerSystem” | Select-Object -ExpandProperty Model
Define output file path
$outputFile = “\MCITS\ITS\HardHash\output.csv”
Create output file if it doesn’t exist
if (-not (Test-Path $outputFile)) {
New-Item -Path $outputFile -ItemType File
}
Append system information to output file
$data = [pscustomobject]@{
SerialNumber = $serialNumber
ProductId = $productId
HardwareHash = $hardwareHash
Model = $model
}
$data | Export-Csv -Path $outputFile -Append -NoTypeInformation