AzureAD - PowerShell - Determine if device has MDM enabled

Method_Dev 41 Reputation points

Is there a good way to do that?

Currently I have:

<# Connect To O365 Start #>
Connect-AzureAD -Credential $credentials | Out-null
<# Connect To O365 End #>

$devices_List = Get-AzureADDevice -Filter "(DisplayName eq 'DESKTOP-DHGUVFV')" | select * #-All $true 
$report = $devices_List | % { 
                   $device = $_
                   $registeredUser = (Get-AzureADDeviceRegisteredOwner -ObjectId $device.ObjectId)
                   Device = $device
                   userInfo = $registeredUser



But it sometimes does not line up with what is shown through the GUI

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
20,123 questions
0 comments No comments
{count} vote

Accepted answer
  1. jLight 201 Reputation points

    Here you go:

    Get-MsolDevice -All -ReturnRegisteredOwners | Where-Object {$_.RegisteredOwners.Count -gt 0}|Select DisplayName,DeviceOsType,DeviceTrustType,RegisteredOwners

    If you still can't find what you are looking for, then it might be time to mess with Graph API

3 additional answers

Sort by: Most helpful
  1. saurabh sharma 76 Reputation points

    You can check for IsManaged property of Get-AzureADDevice cmdlet result. If the value of isManaged parameter is True then device is enrolled and if it is False then device is not enrolled. You can also check for Get-MsolDevice for the same.

  2. jLight 201 Reputation points
    Get-AzureADDevice -All $true | select DisplayName,IsManaged

  3. Axel 1 Reputation point

    The isManagedAttribute is not very reliable.
    What I found out:
    isManaged False —> no corresponding device in intune

    isManaged True —> Device MAY exist in Intune

    isManaged $null —> no corresponding device in Intune