Share via

How to Get Subsites using CSOM PowerShell?

Sayantan Ganguly 80 Reputation points
2023-10-27T13:57:11.7533333+00:00

I have access in SharePoint Admin Centre and i am able to get all of the sites from sharepoint using CSOM PowerShell.

But when i ma trying to get SubSites for each sitesl, I am getting 401 unauthorized for some of the subsites as I do not have access the proper site.

Though I am able to get sites using CSOM PowerShell.

How to get all of the subsites from all sites in sharepoint tenant?

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

Answer accepted by question author

RaytheonXie_MSFT 40,496 Reputation points Microsoft External Staff
2023-10-30T03:22:45.6666667+00:00

Hi @Sayantan Ganguly,

This might caused by you don't have enough permission to the subsite. Although you have permission to access the parenet sites. But some subsites have been granted unique permissions. This means if you are not the member of the sites, you will be unable to get the site. To fix the 401 unauthorized, you will need to check if you have the permission to the subsites or delete the unique permission of the subsites.


If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.