Get-WindowsAutoPilotInfo - A quicker way...

Brass Contributor

Hi All

 

Just a Tip from me to make it easier  (if you got other ways, let me know, would be interested) 

 

 

Starting to deploy via Autopilot but first grabbing the information - so I am using a USB Drive with the following : 

 

Plug in the USB Drive.. 

 

Right Click the file ..GetAutoPilot.cmd and (run as Administrator)   (it seems everytime I plug in the USB I get D: Drive but with the updated command below its automatic )   

 

 

Prepare Files 

 

1) GetAutoPilot.cmd

2) Download a copy of Get-WindowsAutoPilotInfo.ps1

 

Contents of GetAutoPilot.cmd

 

PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command %~d0\Get-WindowsAutoPilotInfo.ps1 -ComputerName $env:computername -OutputFile %~d0\computers.csv -append

 

 

Get-WindowsAutoPilotInfo.ps1 - downloaded from powershellgallery  

https://www.powershellgallery.com/packages/Get-WindowsAutoPilotInfo/1.6

 

What it does... 

It quickly dumps the CSV file onto the USB Drive and now I have all the CSV Files that I need in one file ready to upload to intune. 

 

Then unplug and move onto the next device ...

 

Easy !  

 

Simon Allison    

 

29 Replies
if you add a -append to your cmd it will keep all the hardware IDs in the same csv, making it easier to upload to intune
Slight improvement to your batch file, added -append and set the drive letters to be the drive the bat file is executed from:

PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command %~dp0\Get-WindowsAutoPilotInfo.ps1 -ComputerName $env:computername -OutputFile %~dp0\computers.csv -append

@mac-e updated! thanks makes it even easier

@Simon Allison - do you have a link to the files that I can put onto a usb stick please? struggling to get this to work... ta

@firebladez Try these, put them on the USB stick 

I did run them with the OS installed and through OOBE stage you can get to the command prompt by pressing , press Shift + F10

 

I have put them here...

 

https://github.com/simonallisonuk/Scripts

 

 

Thanks @Simon Allison - I'll give it a go today... :) 

@firebladez 

 

I have just tested and there is an error, but this one works - all I did was remove the "p" as this gives the path and not just the drive.  updating scripts 

 

@ECHO ON
PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command %~d0\Get-WindowsAutoPilotInfo.ps1 -ComputerName $env:computername -OutputFile %~d0\$env:computername.csv

@Simon Allison Hi was having difficulty getting info in the computers.csv but ran Winrm quickconfig.

Now I get "default String" under device serial no. : nothing in windows ; and a very long string of letters under hardware hash. No column for computer name.

Any thoughts?

 

 

hi @Simon Allison - sorry could not get this to work - after running the cmd as admin it had a heap of error then the powershell page closed - it was something like, the client can not connect to the destination specified in the request - and you can not call a method on a null-valued expression... this is what I managed to get from the quick vid I got on my phone 

@firebladezI had to run the following in an elevated CMD prompt:

 

winrm quickconfig

 

That fixed the mass of red being thrown back from the PS script. Hope this helps you

 

@Simon Allison 

 

Hello, thanks for the tip.

I have added the following command on the cmd as it does not work if Windows management service is disabled and it was on my machines : 

net start WManSvc

 

Thanks,

Yohan.

@Simon Allison 

 

The problem where i ran into was that you cannot run the Script when you are in a Public Network.

you need to change it to Private.

 

Then it runs ok.

 

Thanks alot. :)

@Simon Allison Do you know if it's possible to use this without completing Windows setup.  ie During OOBE after networking has been setup?

@Andycap147 the whole process was designed that I know of to run under OOBE, you cant do it on pre-existing setups as it was all designed to run out of the box on new surface devices, as in the background and permissions, and apps etc are from Azure AD and Intune. 

 

I was looking for the same setup where you could use pre-existing windows setups, but sadly it wasnt the case, as you would loose all existing apps.

 

sorry for the late reply 

@Simon Allison 

I can't get this to run... but if i run the get-windowsautopilot.ps1 manually, it works fine so something in that cmd file is not running for me. i can type them line by line and it works up to opening powershell but that's it. after i've opened up powershell from the cmd prompt, then i'm stuck and i can't get the last bit of your code working.

I got mine to work after your tip... but do I have to run this on all the machines first? Any way of adding this to the cmd file?

@Simon Allison ,

Instead of 

PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command %~dp0\Get-WindowsAutoPilotInfo.ps1 -ComputerName $env:computername -OutputFile %~dp0\computers.csv -append,

 

Leave out the -ComputerName variable:

PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command %~dp0\Get-WindowsAutoPilotInfo.ps1  -OutputFile %~dp0\computers.csv -append

 

This defaults the script to localhost, which is what the script sees (I believe) in the OOB screen. Either way, it works. 

Why are you still using .csv files? You can run Get-Windowsautopilotinfo.ps1 -Online to upload it straight to your tenant.

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Install-PackageProvider NuGet -MinimumVersion 2.8.5.201 -Force | Out-Null
Set-PSRepository PSGallery -InstallationPolicy Trusted
Install-Script -Name get-WindowsAutoPilotInfo -Force
Get-WindowsAutoPilotInfo.ps1 -Online

 @Andycap147 Yes, pressing Caps+F10