Export Windows device hardware ID's for InTune Autopilot

This script can be used to export device hardware hashes for InTune Autopilot. The following is a modification of the scripts provided by Microsoft and allow you to more easily collect hardware ID's, the script will automatically elevate and then install the WindowsAutopilotInfo script, then save the device information to the current directory which could be a USB drive or a network location, anything you choose.

You can find the script below published on my github.

Param(
    [string]$Loc
)

$Delay = 1

if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
        [Security.Principal.WindowsBuiltInRole] 'Administrator')
)
{
    Write-Host "Not elevated, restarting in $Delay seconds ..."
    $Loc = Get-Location
    Start-Sleep -Seconds $Delay

    $Arguments =  @(
        '-NoProfile',
        '-ExecutionPolicy Bypass',
        '-NoExit',
        '-File',
        "`"$($MyInvocation.MyCommand.Path)`"",
        "\`"$Loc\`""
    )
    Start-Process -FilePath PowerShell.exe -Verb RunAs -ArgumentList $Arguments
    Break
}
else
{
    Write-Host "Already elevated, exiting in $Delay seconds..."
    Start-Sleep -Seconds $Delay
}
if($Loc.Length -gt 1){
Set-Location $($Loc.Substring(1,$Loc.Length-1)).Trim()
}

Write-Host $(Get-Location)
$SystemInfo = Get-ComputerInfo -Property CsModel, BiosSeralNumber
$FileName = $($SystemInfo.CsModel) + " - " + $($SystemInfo.BiosSeralNumber) + " AutopilotHWID.csv"
$env:Path += ";C:\Program Files\WindowsPowerShell\Scripts"
Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned
Install-Script -Name Get-WindowsAutopilotInfo
Get-WindowsAutopilotInfo -OutputFile $FileName


Was this helpful?

Yes No


Comments