The Get-MgUserOwnedObject cmdlet in Microsoft Graph PowerShell allows administrators to retrieve directory objects that a specific user owns. This can include groups, applications, and other directory-based entities. This cmdlet is particularly useful for auditing user ownerships within an organization’s Microsoft 365 tenant.
Get-MgUserOwnedObject [-UserId ] [-DirectoryObjectId ]
Get-MgUserOwnedObject
This command retrieves the owned objects for the authenticated user running the command.
Get-MgUserOwnedObject -UserId jackie@7xh7fj.onmicrosoft.com
This command returns all directory objects owned by the specified user.
Get-MgUserOwnedObject -UserId jackie@7xh7fj.onmicrosoft.com -DirectoryObjectId a63b372a-0445-4854-9d09-c63ca04539c8
This command filters the results to return only the specific object identified by its DirectoryObjectId.
$users = Get-MgUser -All
foreach ($user in $users) {
Get-MgUserOwnedObject -UserId $user.Id
}
Cause: The provided UserId is incorrect or does not exist. Solution: Verify the user exists using:
Cause: The user does not own any directory objects. Solution: Verify the ownership manually in the Azure portal or check for incorrect filters.
This cmdlet can return groups, applications, and other directory-based objects owned by a user.
Yes, you can loop through multiple users using Get-MgUser -All and pass each user’s ID to Get-MgUserOwnedObject.
Yes, the Directory.Read.All or Directory.ReadWrite.All permission is required to retrieve user-owned objects.
You can use the -Filter parameter to limit the results to groups:
Get-MgUserOwnedObject -UserId user@example.com -Filter "objectType eq 'Group'"
The Get-MgUserOwnedObject cmdlet is a valuable tool for Microsoft 365 administrators, allowing them to identify and manage objects owned by users. Whether for security audits, ownership transfers, or cleanups, this cmdlet provides flexibility in querying directory objects efficiently. By understanding its syntax, usage examples, and troubleshooting common errors, administrators can leverage this cmdlet to maintain a secure and well-organized tenant.
© m365corner.com. All Rights Reserved. Design by HTML Codex