Forum Discussion

Mykey's avatar
Mykey
Brass Contributor
Jul 10, 2023
Solved

Collect Autopilot hashes without big user interaction?

Hi there,

 

is there a way to collect the hashes for the autopilot from existing local Windows 10/11 devices without guiding the user through a powershell script?

You can also export the management protocols directly via the GUI, is there perhaps a batch for this?

Thanks a lot

  • Ok I think I have the solution, with admin rights and the command
    mdmdiagnosticstool.exe -area "Autopilot" -zip "c:\users\public\documents\MDMDiagReport.zip"

    I successfully get a hardware hash.

3 Replies

  • andrewkemp79's avatar
    andrewkemp79
    Copper Contributor
    I ended up using a "custom" version of the Get-WindowsAutoPilotInfo process.
    Rather than running locally I created a script that would run it, export to a CSV based on the PC name and export to Azure Blob storage or you could export to a file share if you'd prefer:

    I then set a PowerShell script to run from Intune, you could use SCCM I guess also if that is what you use.

    you could use the append option to create a single file in a network share. I used Azure Data Factory to merge the CSV's in to one list once it had run.

    #Setup the basics: Folder, Path etc...
    New-Item -Type Directory -Path "C:\HWID"
    Set-Location -Path "C:\HWID"
    $env:Path += ";C:\Program Files\WindowsPowerShell\Scripts"
    Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned

    #Install NuGet and the Get-AutoPilotInfo scrript
    Install-PackageProvider -Name NuGet -Force
    Install-Script -Name Get-WindowsAutoPilotInfo -force

    #Download and install AzCopy
    Invoke-WebRequest -Uri "https://aka.ms/downloadazcopy-v10-windows" -OutFile AzCopy.zip -UseBasicParsing
    #Curl.exe option (Windows 10 Spring 2018 Update (or later))
    curl.exe -L -o AzCopy.zip https://aka.ms/downloadazcopy-v10-windows
    #Expand Archive
    Expand-Archive ./AzCopy.zip ./AzCopy -Force
    #Move AzCopy to the destination you want to store it
    Get-ChildItem ./AzCopy/*/azcopy.exe | Move-Item -Destination "C:\HWID\AzCopy.exe"
    #Add your AzCopy path to the Windows environment PATH
    $userenv = [System.Environment]::GetEnvironmentVariable("Path", "User")
    [System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\HWID\AzCopy", "User")

    #Get the Hardware ID:
    Get-WindowsAutopilotInfo -OutputFile "$env:COMPUTERNAME.csv"
    #Copy the CSV to Azure Blob Storage
    .\azcopy.exe copy "c:\HWID\$env:COMPUTERNAME.csv" "https://mystorage.blob.core.windows.net/autopilot?sp=rw&st=2023-04-10T13:30:52Z&se=2023-08-30T21:30:52Z&spr=https&sv=2021-12-02&sr=c&sig=0A8QGSprlAQJH%2B0cMZdwRL%2Fasdwerwfds45435%$£dfdg" --recursive

    #Cleanup
    Set-Location -Path "C:\"
    Remove-Item -LiteralPath "c:\HWID" -Force -Recurse
    Uninstall-Script Get-WindowsAutoPilotInfo
    • ShadyKhorshed's avatar
      ShadyKhorshed
      Iron Contributor

      hello andrewkemp79 

      As info for you: As I am sure you have noticed, the Get-WindowsAutoPilotInfo script and associated WindowsAutoPilotIntune module have been updated and whether you are using the official one, the authentication method has changed to the Microsoft.Graph SDK.

       

       

      link: https://andrewstaylor.com/2023/06/13/authenticating-to-new-get-windowsautopilotinfo/

       

  • Mykey's avatar
    Mykey
    Brass Contributor

    Ok I think I have the solution, with admin rights and the command
    mdmdiagnosticstool.exe -area "Autopilot" -zip "c:\users\public\documents\MDMDiagReport.zip"

    I successfully get a hardware hash.

Resources