Yes, I tried connecting with "Connect-MgGraph -Scopes "Sites.FullControl.All" ". Approved permissions by Global Admin and it is still not working ...
Get-MgSite : Access denied
Hi All
I am having a lot of issues getting all sites with MS Graph in PowerShell.
Tried with delegated permissions and app-only and constantly getting access denied. Any one came across something similar?
Running: "Get-MgSite -SiteId root" works with no issues, returning site root.
When I try to run: Get-MgSite -Search "Contoso" I get below:
I checked scopes with "(Get-MgContext).Scopes", Admin consent is done everywhere needed.
Anyone any idea, I would appriciate
4 answers
Sort by: Most helpful
-
-
Manu Philip 16,961 Reputation points MVP
2022-08-23T18:44:24.153+00:00 Have you tried connecting the Graph first as below?
Connect-MgGraph -Scopes "Sites.FullControl.All"----------
--please don't forget to
upvote
andAccept as answer
if the reply is helpful-- -
Manu Philip 16,961 Reputation points MVP
2022-08-24T07:55:25.637+00:00 Next thing to check is whether you have give right permission to Microsoft Graph as below:
Check, if the graph permissions are assigned correctly and Granted admin consent for the directory
If this is also not helping, check your application access token in jwt.ms website and see if "Site.Read.All" and "Sites.ReadWrite.All" listed in in roles claim. If not, the token should be corrected
----------
--please don't forget to
upvote
andAccept as answer
if the reply is helpful-- -
RajeshKumarMSFT 1,971 Reputation points Microsoft Vendor
2022-08-24T18:01:36.267+00:00 Hi @Patryk Koprowski ,
Hope you are doing well,
I am able to get the site search results using Get-MgSite -Search "" cmdlet Please follow the attached screen shot and grant the required permissions (Scopes).
If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.