MS AutoPilot Script: export to network share
-
Until I can get a win on the ScriptExecution front, I've come up with a possible way to get a success on getting the needed information to onboard a device into AutoPilot.
POWERSHELL Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -force Echo Setting ExecutionPolicy timeout 3 >nul POWERSHELL Install-Script -Name Get-WindowsAutoPilotInfo -force Echo Getting AutoPilotInfo timeout 20 >nul POWERSHELL Get-WindowsAutoPilotInfo -OutputFile "\\10.7.20.27\IT Resources\!!!_HWID_!!!\!AutoPilot!.csv" -append Echo Saving AutoPilot Info timeout 5 >nul pause
Everything works - except the
OutputFile,
there are number of returned errors, the first being;New-CimSession : WS-Management could not connect to the specified destination.
In talking with @EddieJennings, he suggested saving to the local computer and then copying to the network share. I think that is easily done - but I really wanted to append the file with results over having a single file for each computer.
Of course - I could also go this route, and then merge all the files before importing them into the AutoPilot console.
-
Updated Script - Which does work.
@Echo Off Echo. Echo. POWERSHELL Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -force Echo Setting ExecutionPolicy timeout 2 >nul POWERSHELL Install-Script -Name Get-WindowsAutoPilotInfo -force Echo Getting AutoPilotInfo timeout 20 >nul POWERSHELL New-Item -Type Directory -Path "C:\HWID" POWERSHELL Set-Location -Path "C:\HWID" POWERSHELL Get-WindowsAutoPilotInfo -OutputFile "C:\HWID\AutoPilot_HWID-%computername%.csv" Echo Saving AutoPilot Info timeout 5 >nul Echo Copy to NAS xcopy "C:\HWID\AutoPilot_HWID-%computername%.csv" "\\10.7.20.27\IT Resources\!!!_HWID_!!!" rmdir /Q /S "C:\HWID" pause
Added
rmdir
for clean up.