If enrollment still fails, analyze Windows Event Logs for specific error details and implement advanced troubleshooting techniques.
Examine MDM-related event logs:
# Check Device Management logs
Get-WinEvent -LogName "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" | Where-Object {$_.Id -eq 1006 -or $_.Id -eq 1007} | Format-List TimeCreated, Id, LevelDisplayName, Message
# Check Enrollment logs
Get-WinEvent -LogName "Microsoft-Windows-AAD/Operational" | Where-Object {$_.Message -like "*enrollment*"} | Select-Object TimeCreated, Id, Message
# Check for certificate errors
Get-WinEvent -LogName "Application" | Where-Object {$_.Source -eq "Microsoft-Windows-CertificateServicesClient-Lifecycle-System" -and $_.LevelDisplayName -eq "Error"}
Generate comprehensive diagnostic report:
# Create MDM diagnostic report
$OutputPath = "C:\temp\MDM-Diagnostics-$(Get-Date -Format 'yyyyMMdd-HHmmss').txt"
New-Item -Path "C:\temp" -ItemType Directory -Force
# Gather system information
@"
MDM Diagnostic Report - $(Get-Date)
=====================================
System Information:
$(Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, TotalPhysicalMemory | Out-String)
DSRegCmd Status:
$(dsregcmd /status)
Network Connectivity:
$(Test-NetConnection -ComputerName "enrollment.manage.microsoft.com" -Port 443 | Out-String)
$(Test-NetConnection -ComputerName "portal.manage.microsoft.com" -Port 443 | Out-String)
Enrollment Registry Keys:
$(Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Enrollments" -Recurse -ErrorAction SilentlyContinue | Out-String)
Recent MDM Events:
$(Get-WinEvent -LogName "Microsoft-Windows-DeviceManagement-Enterprise-Diagnostics-Provider/Admin" -MaxEvents 20 -ErrorAction SilentlyContinue | Format-Table TimeCreated, Id, LevelDisplayName, Message -Wrap | Out-String)
"@ | Out-File -FilePath $OutputPath -Encoding UTF8
Write-Host "Diagnostic report saved to: $OutputPath"
Implement final troubleshooting steps:
# Reset Windows Update components (can affect enrollment)
Stop-Service wuauserv, cryptSvc, bits, msiserver -Force
Rename-Item "$env:SystemRoot\SoftwareDistribution" "SoftwareDistribution.old" -Force
Rename-Item "$env:SystemRoot\System32\catroot2" "catroot2.old" -Force
Start-Service wuauserv, cryptSvc, bits, msiserver
# Clear DNS cache
Clear-DnsClientCache
# Reset network stack
netsh winsock reset
netsh int ip reset
Warning: If all troubleshooting steps fail, the issue may require Microsoft Support intervention. Prepare the diagnostic report and error screenshots for support ticket submission.
Verification: Review the diagnostic report for patterns. Successful resolution shows clean event logs, proper registry entries, and successful test connections to Intune endpoints.