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

Get-MGBetaDirectoryDeletedItemAsUser Needs -ConsistencyLevel Switch #2612

Closed
RichWorld-Tech opened this issue Feb 24, 2024 · 7 comments
Closed

Comments

@RichWorld-Tech
Copy link

RichWorld-Tech commented Feb 24, 2024

Describe the bug
This has been an ongoing issue. The -Search cannot work because the -ConsistencyLevel Switch is not available. It is that simple. This is needed in order to automate and retrieve users in the Azure Deleted Users. The -Filter switch only works for certain properties and this function needs to be able to SEARCH on other properties to correctly identify the deleted user. The work around right now id to get all the users in the Deleted Users in Azure and filter with a Where statement. This is not acceptable because of the time it takes and the amount of data transferred. The command needs to be able to SEARCH the OnPremises* and other properties like the Get-MGBEtaUser can do. You must have the -ConsistencyLevel Switch in order for this the work with Graph just like all the other commands

To Reproduce
You can run this SEARCH command against any property. It does not matter because it throws the same error
Get-MGBetaDirectoryDeletedItemAsUser -search "onpremisisuserprincipalname:[email protected]'" -ConsistencyLevel Eventual

Expected behavior
What is expected is it will output all available data as it should.

Debug Output
Debug from above command:
Get-MgBetaDirectoryDeletedItemAsUser: A parameter cannot be found that matches parameter name 'ConsistencyLevel'.

Module Version
Using Microsoft.Graph.Beta Version 2.14.1

Environment Data
Name Value


PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.20348
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

This happens on Windows 11 as well

@calebkiage
Copy link
Contributor

Hello @RichWorld-Tech, thanks for raising the issue. While the commandlet doesn't have a -ConsistencyLevel option yet, it's possible to add it to the request using the -Headers option since ConsistencyLevel is a header on the API. Are you able to use that in your script?

@calebkiage
Copy link
Contributor

related metadata repo issue microsoftgraph/msgraph-metadata#578

@RichWorld-Tech
Copy link
Author

@calebkiage Thank you for the reply and the temporary solution. Get-MGBetaDirectoryDeletedItemAsUser -search "OnPremisesSamAccountName:$identity" -headers @{"ConsistencyLevel" = "Eventual"} Works as expected. As a side note it would be preferred that if "-consistancylevel eventual" is required for every search then it should be a default built into all commands. if you needed to change the -consistancylevel then you can specify as an option but other than that I do not see why it is required on all searches. for all commands .it is just extra code that has to be typed and dealt with. This is similar to the way Export-csv requires the -notypeinformation as the default.

@ricmestre
Copy link

This is an old issue already reported by many, see #513

@calebkiage
Copy link
Contributor

@RichWorld-Tech, I'm happy to help. 🙂

The header is not required for all requests, so we can't really add it as a default. We depend on the OpenAPI description file to tell us which endpoints use that header. Since the workaround works and there's another issue that is similar, I'll close this one for now.

@cgskreddy
Copy link

cgskreddy commented Feb 28, 2024 via email

@calebkiage
Copy link
Contributor

@cgskreddy, could you please open a new issue on this? We like to keep issues on topic and closed issues don't usually get attention from the team.

Thanks for your understanding.

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

No branches or pull requests

4 participants