Device objects in Entra ID include important details such as device ID, display name, operating system, trust type, and last sign-in activity. For IT admins, pulling this information in bulk or retrieving it for a specific group of devices can get challenging, especially when managing large environments. Fortunately, there are efficient methods available to retrieve these details.
Connect-AzureAD
Get-MgDevice
Example query
Connect-MgGraph -Scopes "Device.Read.All"
Get-MgDevice -All | Where-Object { $_.OperatingSystem -eq "Windows" } | Select-Object DisplayName, OperatingSystem, OperatingSystemVersion
Example output
DisplayName OperatingSystem OperatingSystemVersion
----------- -------------- ----------------------
WIN10-LAPTOP01 Windows 10.0.19045.3930
JOHN-DESKTOP Windows 11.0.26100.1742
The syntax is as follows:
Get-MgDevice
[-ExpandProperty <String[]>]
[-Property <String[]>]
[-Filter <String>]
[-Search <String>]
[-Skip <Int32>]
[-Sort <String[]>]
[-Top <Int32>]
[-ConsistencyLevel <String>]
[-ResponseHeadersVariable <String>]
[-Headers <IDictionary>]
[-PageSize <Int32>]
[-All]
[-CountVariable <String>]
[<CommonParameters>]
Example query
Import-Module Microsoft.Graph.Identity.DirectoryManagement
Get-MgDevice -DeviceId "72c3f3f9-2a17-4f55-b4b3-efb7cdb3f82e"
Example output
Id : 72c3f3f9-2a17-4f55-b4b3-efb7cdb3f82e
AccountEnabled : True
DeviceId : 72c3f3f9-2a17-4f55-b4b3-efb7cdb3f82e
DisplayName : Sales-Laptop-01
OperatingSystem : Windows
OperatingSystemVersion : 10.0.22621.2134
DeviceTrustType : AzureAD
DeviceOwnership : Company
IsCompliant : True
IsManaged : True
ManagementType : MDM
ApproximateLastSignInDateTime : 18-08-2025 10:34:22
PhysicalIds : {}
ExtensionAttributes : {}
OnPremisesSyncEnabled :
RegisteredOwners : {Alex Johnson}
RegisteredUsers : {Alex Johnson}
SystemLabels : {}
The output shows a Windows device called Sales-Laptop-01. It’s Azure AD–joined under the company’s ownership, managed through MDM, and marked compliant with policies. The laptop last signed in on Aug. 18, 2025 at 10:34:22. The account is enabled, and both the DeviceId and Id match, confirming its unique identifier in Entra ID. Alex Johnson is listed as both the registered owner and user of the device. Some optional fields like PhysicalIds, ExtensionAttributes, and SystemLabels are empty, which just means no extra tags or labels are applied.
ADManager Plus helps Microsoft 365 admins manage their environment easily with a simple interface that makes daily tasks faster and easier.
Use a Mobile Device Management (MDM) platform to enforce security baselines, push configurations, and monitor device health at scale.
Remove devices that are no longer in use to minimize security exposure and avoid unnecessary license consumption.
Restrict access based on device compliance, user role, or location to maintain a stronger security posture.
If you have a CSV with a column called DeviceName, you can loop through it and fetch object IDs:
$devices = Import-Csv .\devices.csv
foreach ($d in $devices) {
Get-MgDevice -Filter "displayName eq '$($d.DeviceName)'" | Select-Object DisplayName, Id
}
This gives each device's name and its corresponding Object ID from Entra ID.
Using Entra admin center
It's the UI equivalent of running Get-MgUserRegisteredDevice.
Using Graph PowerShell
Get-MgUserRegisteredDevice -UserId "jane@contoso.com" | Select-Object DisplayName, Id, OperatingSystem
The last logged-on user for a device isn't available directly from the Get-MgDevice cmdlet in Entra ID because that object mainly tracks registration and compliance. To see who last signed in, you have two options, which are listed below.
Microsoft Intune
Graph PowerShell
You can query Intune's managed device endpoint.
Get-MgDeviceManagementManagedDevice -Filter "deviceName eq 'Sales-Laptop-01'" | Select-Object DeviceName, UserPrincipalName, LastSyncDateTime
The syntax to filter devices by DeviceId is given below
Get-MgDevice -Filter "deviceId eq '<DeviceId>'"
Example
Get-MgDevice -Filter "deviceId eq '72c3f3f9-2a17-4f55-b4b3-efb7cdb3f82e'"
This pulls the details of the device that matches the given DeviceId.