From def999f23b138d5ddbcbcb210ab2c82cd3a1ad16 Mon Sep 17 00:00:00 2001 From: Owen Fiber Date: Mon, 15 Jun 2026 14:50:31 -0400 Subject: [PATCH] Removed calls to MSGraph. MSGraph is deprecated and replaced by MgGraph. Using MSGraph causes the script to fail. Added optional Connect-MgGraph command for tenants using MFA --- removeAutoPilotdevices.ps1 | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/removeAutoPilotdevices.ps1 b/removeAutoPilotdevices.ps1 index 8b3dbad..1a65c7e 100644 --- a/removeAutoPilotdevices.ps1 +++ b/removeAutoPilotdevices.ps1 @@ -46,11 +46,15 @@ function Check-Module ($m) { Write-Host "`nConnecting to MgGraph`n" Connect-MgGraph -NoWelcome + + # If you have issues connecting and you use MFA in your tenant, use the Connect-MgGraph with the following flag: + # Connect-MgGraph -NoWelcome -UseDeviceAuthentication + # Removed the MSGraph calls. The MSGraph module is deprecated and will throw Application ID not found errors. Use modern MgGraph calls instead. # Connecting with MSGraph might give a problem if module Microsoft.Graph.Intune is not imported - Write-Host "`nConnecting to MSGraph`n" - Update-MSGraphEnvironment -AppId 9a9fdd0a-4fe1-42ce-8dcf-f9e5c90344b3 - Connect-MSGraph + # Write-Host "`nConnecting to MSGraph`n" + # Update-MSGraphEnvironment -AppId 9a9fdd0a-4fe1-42ce-8dcf-f9e5c90344b3 + # Connect-MSGraph # Paths to files