curtcab
curtcab

Reputation: 81

Return users ObjectID from Get-AzureADDevice

Is there a way to grab just the users ObjectID from the Get-AzureADDevice cmdlet? I noticed there is user-gid, gid, user-hwid and hw-id and I need to pull just the users ObjectID.

Thanks

Upvotes: 0

Views: 1559

Answers (1)

Joy Wang
Joy Wang

Reputation: 42043

If I understand correctly, you want to get the ObjectID of the users, you could use the script below.

$devobj = (Get-AzureADDevice).ObjectId
foreach($item in $devobj){
    $DevicePhysicalIds = (Get-AzureADDevice -ObjectId $item).DevicePhysicalIds
    if($DevicePhysicalIds){
        $userobj = $DevicePhysicalIds[0].Split(":")[1]
        Write-Host $userobj
    }else{
        Write-Host "The device has no Owner"
    }  
}

enter image description here

Upvotes: 1

Related Questions