Try using the following request to get the RegisteredOwners and RegisteredUsers attributes.
Get-MgDeviceRegisteredOwner -DeviceId $deviceId
Get-MgDeviceRegisteredUser -DeviceId $deviceId
See the link below for more details:
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.