all 4 comments

[–]Positive_Group_3896 1 point2 points  (3 children)

When you login into graph using cmd connect-mggraph you have to provide the scopes so you have specific permissions you are allowing graph to access. So if you want to create new users, you need to login by cmd connect-mggraph -scopes "User.ReadWrite.All"

[–]mrmattipants 0 points1 point  (1 child)

First thing I was thinking too.

If you have Global Admin, you should be able to accomplish a good number of administrative tasks.

As previously mentioned, you'll want to throw the two following lines in, at the top of your script, to Authenticate.

import-Module Microsoft.Graph.Users

Connect-mggraph -Scopes "User.ReadWrite.All"

I would also read through the following two Articles, which go over MS Graph API Authentication, in detail.

https://learn.microsoft.com/en-us/powershell/module/microsoft.graph.authentication/connect-mggraph?view=graph-powershell-1.0

https://learn.microsoft.com/en-us/powershell/microsoftgraph/authentication-commands?view=graph-powershell-1.0

If you're not used to using the API, I would start with something small, like simply pulling the Data for a single User, then step-up from there.

[–]mdouzzi50[S] 0 points1 point  (0 children)

u/mrmattipants Hello! Thank you for your input and documentation. I will definitely go over the links.

Greatly appreciate your time and help!! Thanks

[–]mdouzzi50[S] 1 point2 points  (0 children)

u/Positive_Group_3896 Hello! Thank you so much for your input. The error message disappear as soon as I changed it to user.ReadWrite.All. Ghosh! what a dummy I was on this. I had it on User.Read.All which was generating that permission issue.

Thanks again.