Home » Office 365 » Get-MsolDevice – Get List of Devices

Get-MsolDevice – Get List of Devices

The Get-MsolDevice cmdlet in PowerShell gets an individual device or a list of devices and information about Microsoft Office 365 devices.

The Get-MsolDevice command can be used to get information about all devices in a tenant or to filter the results to only get information about specific devices.

The syntax to get device objects that are registered in Microsoft Azure Active Directory is given below.

Get-MsolDevice
   -Name <String>
    [-All]
   -DeviceId <Guid>
   -LogonTimeBefore <DateTime>
   -ObjectId <Guid>
   -RegisteredOwnerUpn <String>
  -IncludeSystemManagedDevices
   [<CommonParameters>]

In this article, we will discuss how to use the Get-MsolDevice cmdlet in PowerShell to get a device object, a list of devices, a list of device objects that contains the registered owner’s property, get a device by device ID.

How to Get a Device Object in Microsoft 365

To get a device object from the Azure Active Directory, use the following command.

Get-MsolDevice -Name "TEST01"

This command returns a device object that is named “TEST01” in Office 365.

How to Get a List of Device Objects in Office 365

To get a list of device objects in Office 365 with PowerShell, use the following command.

Get-MsolDevice -All

This command gets a list of all device objects that are registered in your Azure AD tenant.

How to Get a Device by Device ID in Microsoft 365

To get a device object by device ID in Microsoft 365, run the following command.

Get-MsolDevice -DeviceId "44b30b26-aa3e-222c-3446-641fcf094fb1"

This command gets device information about the device specified with the -DeviceId parameter.

How to Get a Device Object by Object ID in Microsoft 365

To get a device object by object ID, run the following command.

Get-MsolDevice -ObjectId "332A2AB4-6CD1-2A2B-AD12-C2A233AC26A7"

The Get-MsolDevice command in PowerShell uses the -ObjectId parameter to specify the unique ID of the device and returns the device information.

How to Get Devices Registered by UserPrincipalName

To get a list of devices registered by the user with UPN, run the following command.

Get-MsolDevice -RegisteredOwnerUpn "[email protected]"

The Get-MsolDevice command uses the -RegisteredOwnerUpn parameter to specify the user object that is the registered owner of the device by specifying the user principal name (UPN). It gets all device objects registered by UPN named “[email protected]“.

How to Get a List of Device Objects that Contains the RegisteredOwners Property

To get a list of device objects that contain the registered owner property, run the following command.

Get-MsolDevice -All -ReturnRegisteredOwners

The Get-MsolDevice command uses the -ReturnRegisteredOwners parameter that specifies the device object contains the registeredOwners property.

How to Get a Device by Activity (Logon) TimeStamp

To get all the devices with the ApproximateLastLogonTimestamp before October 15, 2021, run the following command.

Get-MsolDevice -All -LogonTimeBefore 'October 15, 2021 12:00:00 AM'

What is the Output of Get-MsolDevice?

The Get-MsolDevice cmdlet in PowerShell returns device objects, which include the following information.

  • AccountEnabled: The device’s status: is enabled or disabled.
  • ObjectId: The device’s unique ID.
  • DeviceId: The device’s device ID.
  • DisplayName: The device’s display name.
  • DeviceObjectVersion: The device’s object version number.
  • DeviceOSType: The device operating system type.
  • DeviceOSVersion: The device operating system version number.
  • DeviceTrustType: The device trust type. The value could be one of the following: Workplace Joined, AzureAD Joined, Domain Joined.
  • DeviceTrustLevel: The device trust level. The value could be one of the following: Authenticated, Compliant, Managed.
  • DevicePhysicalIds: The device physical Ids.
  • ApproximateLastLogonTimestamp: The last logon timestamp using this device.
  • AlternativeSecurityIds: The device alternative security Ids.
  • DirSyncEnabled: If the device is enabled with DirSync.
  • LastDirSyncTime: The last timestamp the device was synchronized by DirSync.
  • RegisteredOwners: The device’s registered owner.
  • GraphDeviceObject: The device object returned from graph API.

Conclusion

I hope the above article on how to use Get-MsolDevice to get information about device objects that are registered in Office 365 is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Related Links

Enable-MsolDevice

Disable-MsolDevice

Remove-MsolDevice