Score:0

PnP - Sharepoint site members and site Owners

cn flag

I'm trying to pull site 'members' along with 'department details, 'job title' as well as other attributes per site. The results pretty confusing as I'm unable to differentiate between site 'owners','admin', 'members' and 'visitors'. The goal is only to list the site members.

So advise around files or item total's per site would be really helpful, I'm to sure on the best solution, looping Get-PnPList doesn't appear to be working.

Connect-PnPOnline -Tenant **** -Url $adminSiteUrl

$sites = Get-PnPTenantSite -Detailed | Select-Object

$results = @()

foreach($site in $sites) {

Connect-PnPOnline -Url $site.Url  -Tenant ***

$sitename = $site.Title
$siteurl = $site.Url
$groups = Get-PnPGroup

$userResults = foreach ($group in $groups){

$members = Get-PnPGroupMember -Identity $group.LoginName

    foreach ($member in $members) {
$user = Get-PnPUserProfileProperty -Account $member.LoginName

$Data = [PSCustomObject]@{

Name = $sitename
URL = $Siteurl
Owner = $site.Owner
Member = $user.DisplayName
MemberDepartment = $user.'SPS-Department'
MemberJobTitle = $user.Title

                        }
                                                                  
                                         }
$results += $Data }

$results
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.