Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪲 Inconsistent output for Get-EntraObjectByObjectId #1366

Open
scottm19468 opened this issue Feb 18, 2025 · 5 comments
Open

🪲 Inconsistent output for Get-EntraObjectByObjectId #1366

scottm19468 opened this issue Feb 18, 2025 · 5 comments
Labels

Comments

@scottm19468
Copy link

Thanks for reporting the bug. Please ensure you've gone through the following checklist before opening an issue:

  • Make sure you can reproduce this issue using the latest released version of Microsoft.Entra or Microsoft.Entra.Beta.
  • Please search the existing issues to see if there has been a similar issue filed.

Describe the bug

When using Get-AzureADObjectByObjectId it returns the expected object. When doing this with Get-EntraObjectByObjectId, it does not return the expected object. In my case, it doesn't return anything.

To Reproduce

Steps to reproduce the behavior:

  1. Get-AzureADObjectByObjectId -ObjectIds 'objectid'
    'returns object'
  2. Get-EntraObjectByObjectId -ObjectIds 'objectid'
    'returns nothing'

Expected behavior

I expect the Entra command to return the same answer as the AzureAD command does.

Debug Output

⚠ ATTENTION: Be sure to remove any sensitive information that may be in the logs.

Debug Output Get-EntraObjectByObjectId -ObjectIds 729827e3-9c14-49f7-bb1b-9608f156bbb8 -debug DEBUG: ============================ TRANSFORMATIONS ============================

DEBUG: =========================================================================

DEBUG: POST /v1.0/directoryObjects/microsoft.graph.getByIds?$select=* HTTP/1.1
HTTP: graph.microsoft.com
User-Agent: PowerShell/5.1.14393.6343 EntraPowershell/1.0.1 Get-EntraObjectByObjectId
Content-Length: 48
Content-Type: application/json
{"Ids":["729827e3-9c14-49f7-bb1b-9608f156bbb8"]}
DEBUG: POST https://graph.microsoft.com/v1.0/directoryObjects/microsoft.graph.getByIds?$select=*
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Vary: Accept-Encoding
Strict-Transport-Security: max-age=31536000
request-id: e8d5a962-61d4-4823-9525-c3c2b97530f9
client-request-id: 2719b8de-6755-4cdd-9ab6-76cb242c2568
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"East
US","Slice":"E","Ring":"5","ScaleUnit":"008","RoleInstance":"BL02EPF0001B4CD"}}
x-ms-resource-unit: 3
OData-Version: 4.0
Cache-Control: no-cache
Date: Tue, 18 Feb 2025 19:52:54 GMT
Location: https://graph.microsoft.com/
Content-Encoding: gzip
Content-Type: application/json; odata.metadata=minimal; odata.streaming=true; IEEE754Compatible=false;
charset=utf-8
{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#directoryObjects(*)","value":[]}

Module Version

ModuleType Version Name


Script 1.0.1 Microsoft.Entra.Authentication
Script 1.0.1 Microsoft.Entra.DirectoryManagement
Script 1.0.1 Microsoft.Entra.Groups

Environment Data

Name Value


PSVersion 5.1.14393.6343
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.6343
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Screenshots

Image

Additional context

@alexandair
Copy link
Collaborator

I am using Microsoft.Entra 1.0.2, and I don't even have Get-EntraObjectByObjectId command.

@SamErde
Copy link
Collaborator

SamErde commented Feb 19, 2025

@scottm19468, try updating to Microsoft.Entra v1.0.2 and using the new Get-EntraDirectoryObject function which supports looking up objects by ID.

It has a defined alias of Get-EntraObjectByObjectId, indicating that it has replaced the old function with one that is easier to use and easier to type. 👍

@SamErde
Copy link
Collaborator

SamErde commented Feb 19, 2025

@stevemutungi, should the moduleMapping.json file[s] be updated to include Get-EntraDirectoryObject and remove Get-EntraObjectByObjectId (or do you still map aliases)?

Image

@alexandair
Copy link
Collaborator

Get-EntraObjectByObjectId should be also added to the AliasesToExport list in Microsoft.Entra.DirectoryManagement.psm1 file.

@scottm19468
Copy link
Author

Thanks for the feedback. However, the result is the same with Get-EntraDirectoryObject. However, I think I have found the issue. In the AzureAD module it was allowing me to look up a role definition via the RoleTemplateID as well as the object ID of the role. See object below.

deletedDateTime :
id : 0ac42763-0fdd-43b5-9db7-c5f8cc732f0b
roleTemplateId : d2562ede-74db-457e-a7b6-544e236ebb61
displayName : AI Administrator
@odata.type : #microsoft.graph.directoryRole
description : Manage all aspects of Microsoft 365 Copilot and AI-related enterprise services in Microsoft 365.
AdditionalProperties : {}

So this works:

Get-AzureADObjectByObjectId -ObjectIds d2562ede-74db-457e-a7b6-544e236ebb61

But this does not.

Get-EntraDirectoryObject -DirectoryObjectIds d2562ede-74db-457e-a7b6-544e236ebb61

However, this does work.

Get-EntraDirectoryObject -DirectoryObjectIds 0ac42763-0fdd-43b5-9db7-c5f8cc732f0b

So maybe it isn't a bug, but it is a loss of functionality. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants