Issues with PowerShell Graph Commands and Client ID Errors
Asked by
TechExplorer88
I'm having trouble running various Graph commands in PowerShell after successfully connecting using my credentials with 'connect-mggraph'. I see that 'get-mgcontext' gives me all the right details like the client ID and tenant ID, but when I try to execute commands like 'get-mguser', I encounter an error. The error appears in an interactive auth window that states: 'AADSTS900144: The request body must contain the following parameter: 'client_id'.' I've attempted to resolve this by uninstalling and reinstalling the Graph modules, rebooting my system, and even switching devices and apps (from ISE to VSCode), but nothing has worked. Any suggestions on how to fix this?
Answers
Have you tried connecting with specific scopes? You can add something like 'Connect-MgGraph -Scopes โUser.Read.Allโ' to see if that helps.
Reply to this answer
It's possible you have multiple versions of the Graph module installed. Check that 'connect-MgGraph' is pulling from the correct version. You can use 'Invoke-MgGraphRequest' which should get pulled from the same loaded module as 'connect-mggraph', so it should work for commands afterward.
Reply to this answer
Can you share your script? Itโs tough to troubleshoot without seeing what youโre working with.
TechExplorer88: Here's the weird part. No actual script. Just connect-mggraph and then get-mguser -userID and then I get that error popup.
Reply to this answer
I've seen discussions about issues arising from the latest version. You might want to uninstall all the Graph modules and then reinstall version 2.25.0 specifically with:
Install-Module -Name Microsoft.Graph -RequiredVersion 2.25.0
TechExplorer88: Hm, ok let me try that, thanks!
Reply to this answer
Add your answer
Answers are reviewed before publication.
TechExplorer88: Tried Connect-MgGraph -Scopes "Directory.ReadWrite.All", "DeviceManagementManagedDevices.ReadWrite.All", "DeviceManagementConfiguration.ReadWrite.All" -NoWelcome and connected successfully, but still no luck with other commands :/