Manually registering devices for Windows Autopilot via CSV upload can be a hassle – especially during on-site deployments or when dealing with just a handful of machines. This PowerShell script simplifies the process by uploading Autopilot info directly to Intune via Microsoft Graph.
✅ What the script does
- Installs required PowerShell components (NuGet, modules, scripts)
- Prompts for an optional Group Tag
- Collects device hardware info
- Uploads everything straight to Intune – no CSV needed
💡Why use it?
Perfect for small environments, field setups, or when you just need to get a device enrolled fast. No need to export a file, no Intune portal, no manual steps – just run the script and you’re done.
🔐 Required Graph permission
Your app registration (Enterprise App) needs the following Application permission in Microsoft Graph:
DeviceManagementServiceConfig.ReadWrite.All
This permission is required – there’s no more limited alternative for this scenario.
⚠️ But be aware:
This permission gives your app far more access than just uploading Autopilot devices. With this single permission, the app could also:
- Add or remove iOS devices and VPP tokens
- Add or remove connectors (e.g. Apple DEP, Android EMM)
- Modify or remove enrollment restrictions
- Create or change device compliance policies
- Even add or remove users in your Entra ID tenant
🛠 How to use it
- Download the script
- Enter your Tenant ID, App ID, and App Secret
- Run it on the target device (admin rights required)
<#
Script: Autopilot Intune Upload Script with Group Tag Prompt
Author: Daniel Fraubaum
Version: 1.0
Description: Collects Autopilot info from device and uploads it to Intune. Optionally allows entering a Group Tag interactively.
#>
####################################################################
# Set execution policy (session only)
####################################################################
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted -Force
####################################################################
# Install required components (silent)
####################################################################
Write-Host "`n[i] Installing required components ..." -ForegroundColor Cyan
Install-PackageProvider -Name NuGet -Force | Out-Null
Install-Script -Name Get-WindowsAutoPilotInfo -Force -ErrorAction Stop | Out-Null
Install-Module -Name WindowsAutopilotIntune -Force -ErrorAction Stop | Out-Null
####################################################################
# Ask for optional Group Tag
####################################################################
$GroupTag = Read-Host "To upload with a Group Tag, enter it now. Otherwise, press Enter to continue without"
####################################################################
# Define parameters
####################################################################
$AutopilotParams = @{
Online = $true
TenantId = "xxxxxxxxxx"
AppId = "yyyyyyyyyyyyyyyy"
AppSecret = "bbbbbbbbbbbbbb"
GroupTag = $GroupTag
}
####################################################################
# Upload Autopilot info to Intune
####################################################################
Get-WindowsAutoPilotInfo @AutopilotParams
####################################################################
# Wait for user input, then reboot
####################################################################
Write-Host "`n[i] Press Enter to reboot the device now ..." -ForegroundColor Cyan
[void][System.Console]::ReadLine()
Restart-Computer -Force
Optional: Turn the script into a .exe
To simplify usage for helpdesk or field engineers, you can compile the PowerShell script into a .exe
file. This makes it easier to distribute and avoids exposing the script contents directly.
Here’s how:
- Install PS2EXE module: powershell
Install-Module -Name ps2exe -Scope CurrentUser
- Convert the script:
Invoke-PS2EXE -InputFile .\Register-Autopilot.ps1 -OutputFile .\Register-Autopilot.exe -NoConsole -RequireAdmin
Now you have a single .exe
file you can hand over to end users or field techs.
Leave a Reply