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?
4 Answers
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
Can you share your script? It’s tough to troubleshoot without seeing what you’re working with.
Here's the weird part. No actual script.
Just
connect-mggraph
and then
get-mguser -userID
and then I get that error popup.
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.
Have you tried connecting with specific scopes? You can add something like 'Connect-MgGraph -Scopes “User.Read.All”' to see if that helps.
Tried Connect-MgGraph -Scopes "Directory.ReadWrite.All", "DeviceManagementManagedDevices.ReadWrite.All", "DeviceManagementConfiguration.ReadWrite.All" -NoWelcome and connected successfully, but still no luck with other commands :/
Hm, ok let me try that, thanks!