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
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 !
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