question

EdizNoah-3843 avatar image
0 Votes"
EdizNoah-3843 asked Romain-2064 commented

Get AutoPilotHash in WinPE

Hello everbody

I am writing because of an error message in WinPE. I want to create a USB stick which automatically reads the hardware hash and serial number and writes that to a CSV. Like in the following article: https://docs.microsoft.com/en-us/mem/autopilot/add-devices

The WinPE works perfectly so far and I have Powershell mounted in it as well.
First I start Powershell with the following script:

> CMD Script

powershell.exe "Start-Process powershell -ArgumentList '-ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File E:\mount\Autopilot\Script\Get-AutopilotHash.ps1' -Verb RunAs"


After that this PowerShell script is executed, everything works so far. I have already saved the script from Microsoft "Get-WindowsAutoPilotInfo".

(as info, everything works on a normal computer)

> PowerShellScript:

$SN = (gwmi win32_bios).SerialNumber
$ROOT = get-psdrive |where {$.Root -match ":"} |% {if (Test-Path ($.Root + "AutopilotCSV")){$_.Root}}
$outfilename = "$($SN)_AutoPilotHWID.csv"
Set-Location "$($ROOT)\AutopilotCSV"
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
. "$($Root)\mount\Program Files\WindowsPowerShell\Scripts\Get-WindowsAutoPilotInfo.ps1" -outputfile $outfilename
Start-Sleep -s 15
Stop-Computer -ComputerName localhost


The script reads the drive letter automatically by looking where a folder named AutoPilotCSV is.
With a Windows To Go on a USB stick is it working

The error messages are these:

73473-get-ciminstance.jpg


Thanks for everyone


windows-10-generalwindows-server-powershellwindows-apiwindows-10-setup
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @EdizNoah-3843,
The windows-forms tag is discussing and asking questions about the Windows Forms such as Winforms controls, libraries, samples, publication and installation.
The supported products are listed over here (more to be added later on).
Thank you for your understanding.
Best Regards,
Daniel Zhang


1 Vote 1 ·

1 Answer

StefanT-5192 avatar image
0 Votes"
StefanT-5192 answered Romain-2064 commented

Hi, it might be too late for you, but I registered to answer your question since I was working on the same yesterday.
I found that it is not possible to do this in Windows PE. But you can do it in a Full Windows environment. So I built myself a Windows on a Stick and automated the hash collection that way.

But I have yet to test if it actually works for different Machines (is the hash generated correctly for each machine I boot of the stick, or is it a generic hash based on the Install on the stick itself...).

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, thank you for your reply. I have now done the same as you. I have installed a Windows To Go on a stick and an automatic start of the script. Everything does it automatically. Thank you

0 Votes 0 ·

Hello,
I'm looking for exactly this kind of solution (I was first look to a solution with WinPe and then found your post).
I've never created a Window to Go key and so also don't know how to launch automaticaly a script at startup. Do you have any link about it pls ?
Tks in advance
Romain

0 Votes 0 ·

Hello,
Concerning the creation of windows to go key found it, and I'll just create a scheduled task starting at session logon.

I'm working on the script and have issues, launching manually from a PS console launch as administrator (I'm log with administrator local session) it works, but if I'm launch it from a PS sessions not lauche as (by right clik, launch as) it fails. I've tried to launch the scritp with -verb RunAs option but the script always failed with error about permissions.

I'm missing something ? I'm not seeing what's wrong here...

Tks in advance

Romain

0 Votes 0 ·