Forum Discussion

nabin pokharel's avatar
nabin pokharel
Copper Contributor
Feb 13, 2019

Getting the List of all sites/ sub-sites and their owners using PnP

Hi,

 

I am trying to get the list of all the SharePoint sites/ sub-sites that I have access to in my tenant in SharePoint Online. Also I have to make a list of all the sites/ sub-sites with their Owners. What is the best way to achieve this?

If script is needed, PnP is preferred.

 

I am trying to achieve this using PnP but haven't figured out yet. Here's what I have done:

1. Get list of all sites in the tenant : 

Get-pnptenantsite

2. For each site collection, find the list of sites and subsites: 

get-pnpsubwebs -recurse

3a. I don't know how to get the list of users in each subsite. I tried 

get-pnpusers

, but it is giving the users at top level site collection not sub-sites.

3b. I can find the site admin using IsAdmin is true, but can't find the Owners (both individuals and group)

 

Thanks,

Nabin

Resources