Getting device details from Azure with PowerShell

Intune PowerShell SDK

Install the Intune PowerShell SDK with the command:

Install-Module -Name Microsoft.Graph.Intune

Give admin consent with:

Connect-MSGraph -AdminConsent

List all the managed Intune devices:

Get-DeviceManagement_ManagedDevices

This will get the following properties unless else specified:

id                                        : d1484265-945e-2341-b527-772415178167
userId                                    : 5fa8884-2832-2423-af03-h35436882454
deviceName                                : DESKTOP-101ALUB
managedDeviceOwnerType                    : personal
enrolledDateTime                          : 12.07.2018 11:12:01
lastSyncDateTime                          : 12.07.2018 12:45:02
operatingSystem                           : Windows
complianceState                           : noncompliant
jailBroken                                : Unknown
managementAgent                           : mdm
osVersion                                 : 10.0.18362.30
easActivated                              : True
easDeviceId                               : 745712154246848731B628312875278A
easActivationDateTime                     : 01.01.0001 00:00:00
azureADRegistered                         : True
deviceEnrollmentType                      : windowsAutoEnrollment
activationLockBypassCode                  :
emailAddress                              : christopher.morgan@abcompany.com
azureADDeviceId                           : c3814471-985d-777s-926e-856647377652
deviceRegistrationState                   : registered
deviceCategoryDisplayName                 : Unknown
isSupervised                              : False
exchangeLastSuccessfulSyncDateTime        : 01.01.0001 00:00:00
exchangeAccessState                       : none
exchangeAccessStateReason                 : none
remoteAssistanceSessionUrl                :
remoteAssistanceSessionErrorDetails       :
isEncrypted                               : False
userPrincipalName                         : christopher.morgan@abcompany.com
model                                     : VMware7,1
manufacturer                              : VMware, Inc.
imei                                      :
complianceGracePeriodExpirationDateTime   : 12.07.20189 02:06:12
serialNumber                              : VMware-564d06348abc6603-44e7466dad61ffcd
phoneNumber                               :
androidSecurityPatchLevel                 :
userDisplayName                           : Cristopher Morgan
configurationManagerClientEnabledFeatures :
wiFiMacAddress                            :
deviceHealthAttestationState              :
subscriberCarrier                         :
meid                                      :
totalStorageSpaceInBytes                  : 64422527477
freeStorageSpaceInBytes                   : 40903822375
managedDeviceName                         : cristopher.morgan_Windows_7/12/2018_11:12 AM
partnerReportedThreatState                : unknown
deviceActionResults                       : {}

Get the devices of a user in Azure:

Get-IntuneManagedDevice | Where-Object {$_.emailAddress -like "some.dude@example.com"}

You can make a list of all the users who have registered one device or more with the command:

Get-IntuneManagedDevice | Select emailAddress | Sort-Object emailAddress -Unique

The value Unique will print out the users only once even if they have multiple devices. Result:

angelacruz@abcompany.com
meganwallace@abcompany.com
kfoster@abcompany.com
richard03@abcompany.com
joseph77@abcompany.com
susan31@abcompany.com
douglas75@abcompany.com
anthonyvaldez@abcompany.com
jenniferjones@abcompany.com
jean@abcompany.com

You can also exclude some users, in case you have for example admin users you do not want to list:

Get-IntuneManagedDevice | Where-Object {$_.emailAddress -notlike "user1@example.com" -and $_.emailAddress -notlike "user2@example.com"} | Select emailAddress | Sort-Object emailAddress -Unique

Finally, you can also add measure to just count how many users you have with one or more registered devices:

Get-IntuneManagedDevice | Select emailAddress | Sort-Object emailAddress -Unique | measure

Result:

Count    : 631
Average  :
Sum      :
Maximum  :
Minimum  :
Property :

Azure Active Directory PowerShell for Graph module

List all devices in Azure by owner of the device. This can take a while…

Get-AzureADDevice -All $True | select DisplayName,DeviceTrustType,DeviceOSType,AccountEnabled,@{n="Owner";e={(Get-AzureADDeviceRegisteredOwner -ObjectId $_.ObjectId).DisplayName}} | Sort-Object Owner | ft -autosize

Result:

DisplayName                              DeviceTrustType DeviceOSType AccountEnabled Owner
-----------                              --------------- ------------ -------------- -----
Maria iPhone                             Workplace       iPhone                 True Cherish Putnam
Kent-SurfaceBook                         AzureAd         Windows                True Kent Michaels
MJOHNSTEVE-P51                           Workplace       Windows                True John Stevenson
Richard iPhone                           Workplace       iPhone                 True Richard Wilson
DESKTOP-ABC123B                          AzureAd         Windows                True Martin King

Leave a Reply

Your email address will not be published. Required fields are marked *