Reputation: 81
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
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"
}
}
Upvotes: 1