Description:
Automating the enrollment of devices into Microsoft Intune can save time, especially when managing large environments. This post provides a PowerShell script example to enroll a device into Intune.

PowerShell Script:

if (-not (Get-Module -ListAvailable -Name Microsoft.Graph.Intune)) {
    Install-Module -Name Microsoft.Graph.Intune -Force
}

# Connect to Microsoft Graph API using Intune admin credentials
Connect-MSGraph

# Prompt for Intune admin credentials
$adminCredentials = Get-Credential -Message "Enter your Intune admin credentials"

# Get the device enrollment configuration
$enrollmentConfiguration = Get-IntuneDeviceEnrollmentConfiguration

# Enroll the device using the automatic enrollment configuration
$enrollmentResult = Add-IntuneManagedDevice -Credential $adminCredentials -DeviceEnrollmentConfiguration $enrollmentConfiguration

# Display the enrollment result
Write-Host "Device enrollment result:"
$enrollmentResult

This script helps automate the enrollment process by using the Microsoft Graph API and the Intune PowerShell module. Adjust the script based on your environment and ensure you have the correct permissions.

Note: Before running this script, test it in a non-production environment to ensure it meets your needs and doesn’t cause any disruptions.

Tags:

#PowerShell #Intune #DeviceManagement #Automation