My company acquired a smaller company with about 70 laptops. We are trying to get the Hardware Hash of all those laptops in an automated way so we can reimage the laptops with your Intune using autopilot. For that, I build a PowerShell script that I am trying to deploy as a Win32 app on that company. This script will get the hardware hash and upload it to an Azure Blob.
The script works perfectly if I run it locally with admin rights on the machine. The detection method, I am using manual detection with a file that the scripts create called hashidconfirm.txt. The command that I am using is powershell.exe -ExecutionPolicy Bypass -File .\hashid.ps1 in the install field in the Win32 configuration.
However, the script does not work when deployed this way, and I can not figure out why. Am I doing something wrong?
#Define variables
Install-Module -Name Az.Storage -force
Install-Script -Name Get-WindowsAutoPilotInfo -force
$StorageAccountName = "XXXXX"
$StorageAccountKey = "XXXXXX"
$ContainerName = "XXXXX"
$Serial = (Get-CimInstance win32_bios).SerialNumber
$Context = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $StorageAccountKey
New-Item -ItemType Directory -Path C:\Intune\
#Create the local file
Get-WindowsAutoPilotInfo -Outputfile C:\Intune\$Serial.csv
#Upload the file to Azure blob storage
Set-AzStorageBlobContent -Context $Context -Container $ContainerName -File "C:\Intune\$Serial.csv"
#Delete the local file
Remove-Item -Path "C:\Intune\$Serial.csv"
New-Item -Path "C:\Intune\hashidconfirm.txt"
I am expeting to get the hardware hash ids using a powershell script deployed with intune
I tried this below to get the hardware hash and upload it to an Azure Blob.
With powershell:
With ISE: