User Tools

Site Tools


show_info_on_all_devices_in_an_entra_id_group

This is an old revision of the document!


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 -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.1710491766.txt.gz · Last modified: by thomas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki