show_info_on_all_devices_in_an_entra_id_group
Show info on all devices in an Entra ID group
This script gets some information on every device that's a member of an Entra ID group. You just need to adjust the $groupId parameter on the first line. The result will be a devices.csv file in the working directory.
$GroupId = "caac8b5d-119d-4dbb-b943-1b46055cfd0d" Connect-MgGraph $Members = Get-MgGroupMember -All -GroupId $GroupId $Results = @() ForEach($Member in $Members) { $Device = Get-MgDevice -DeviceId $Member.Id $User = Get-MgDeviceRegisteredUser -DeviceId $Member.Id If($User.Id) { $UserName = (Get-MgUser -UserId $User.Id).DisplayName } Else { $UserName = "<No User Assigned>" } $Result = [PSCustomObject]@{ UserName = $UserName DeviceName = $Device.DisplayName OperatingSystem = $Device.OperatingSystem OperatingSystemVersion = $Device.OperatingSystemVersion ApproximateLastSignInDateTime = $Device.ApproximateLastSignInDateTime } $Results += ,$Result } $Results | Export-Csv -Path devices.csv
show_info_on_all_devices_in_an_entra_id_group.txt · Last modified: by thomas
