1

I'm preparing laptops with Autopilot Intune Enrollment but we need to import hash in Endpoint automatically We got multiples command lines to enter in cmd, look like that

powershell
Set-Executionpolicy Bypass
Install-Script -Name Get-WindowsAutoPilotInfo
Get-WindowsAutopilotInfo.ps1 -Online -Assign

Issue here, the line with Install-Script always ask for 3 differents prompts : Twice "y" to enter and once "a" at the end

Resulting prompt

But we lose too much time doing this for each laptop.

So I tried implement echo command and it's look like that :

powershell
Set-Executionpolicy Bypass
echo "y" | Install-Script -Name Get-WindowsAutoPilotInfo
echo "y" | Install-Script -Name Get-WindowsAutoPilotInfo
echo "a" | Install-Script -Name Get-WindowsAutoPilotInfo
Get-WindowsAutopilotInfo.ps1 -Online -Assign

But it's not working and I can't figured out why, even if I've tryed different type of configurations for this.

Anybody had ideas ? I'm not very confident in powershell unfortunately to solve it by myself

Thanks in advance !

  • 1
    Try `Install-Script -Name Get-WindowsAutoPilotInfo -Confirm:$false` – Mathias R. Jessen Feb 04 '22 at 19:08
  • Why not resolve the issues that are causing the prompts before you get the prompts? Set your path, add the NuGet provider, and set the repo to trusted. Then you won't get prompted. – TheMadTechnician Feb 04 '22 at 19:08
  • Thanks @MathiasR.Jessen I'll try this when possible @TheMadTechnician Not sure how I can do that tbh. As laptops I'm deploying are freshly deployed, nothing is set. Can I add somme command lines to automatize it ? Like `Set-path` or something ? – Joachim Demiguel Feb 04 '22 at 20:26
  • Hello @MathiasR.Jessen, I've tried several compositions with your proposal but no one worked `Install-Script -Name Get-WindowsAutoPilotInfo -Confirm:$false` `echo y | Install-Script -Name Get-WindowsAutoPilotInfo -Confirm:$false` `Write-Output y | Install-Script -Name Get-WindowsAutoPilotInfo -Confirm:$false` Tried also `"y"` and `'y'` but didn't worked either Any further idea ? – Joachim Demiguel Feb 08 '22 at 10:27

1 Answers1

1

After some further research, mixing both suggested solutions give me that :

Set-Executionpolicy Bypass -Force
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Confirm:$False
Install-Script -Name Get-WindowsAutoPilotInfo -Force -Confirm:$False
powershell.exe -ExecutionPolicy Bypass Get-WindowsAutopilotInfo.ps1 -Online -Assign

Sources : https://learn.microsoft.com/en-us/powershell/module/powershellget/install-script?view=powershell-7.2