A stone building with a clock tower in the background

How to Add a Device to Intune Using PowerShell

Description:
Automating the enrollment of devices into Microsoft Intune can save time, especially when managing large environments. This post provides a 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 #

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

WordPress Cookie Plugin by Real Cookie Banner