Hi All,
I'm using PNP modules to iterate through each subweb so I can extract into a file the following information for each site:
URL, Site Title, Owner/s
I need to script to go through each site and find the users that have full control permission and I also need to go into any office 365 groups that are attached to the site and display those names too.
I have attached what I have so far however the groups and names are currently just pulling all from the site collection - not what I need which is I need to pull the full control permission list of users who are attached to each site.
Sorry for the very basic script - I am just starting to delve into PowerShell!
Connect-PnPOnline -url "team site" $Sites = get-pnpsubwebs -recurse $Groups = Get-PnPGroup $UserList = Get-PnPUser $FileUrl = "c:\temp\SPOSiteList.csv" #Write CSV- TAB Separated File) Header "URL, Site Name, Groups, Users" | set-content $FileUrl foreach($web in $Sites){ "$($web.url), $($web.Title)" | out-file $FileUrl -Append foreach($groupname in $groups){ ", , $($groupname.title)" | out-file $FileUrl -Append } foreach($user in $UserList){", , , $($user.title)" | out-file $FileUrl -Append } $sites.dispose() $groups.dispose() $UserList.dispose() }
Thanks in advance!
Clare