简体   繁体   中英

How to properly get list permissions SharePoint PnP

I need to retrieve the permissions of a list in order to perform an extraction for a list and its members.

The problem is that the current script lists absolutely all the groups assigned to lists. Here is a piece of the code

Connect-PnPOnline -url "https://xxx.sharepoint.com/sites/XXXX" -UseWebLogin
$list = Get-PnPList -Identity "ListName" -Includes RoleAssignments
foreach($ra in $list.RoleAssignments) {
    $member = $ra.Member
    $loginName = Get-PnPProperty -ClientObject $member -Property LoginName
    Write-Host "`r$loginName"
}

Normally knowing that I specify the list at the beginning the script should return that the groups concerned by the list

You code works correctly. I noticed that when the List property of "HasUniqueRoleAssignments" = false, then the results of the code will shows just for that list.

When "HasUniqueRoleAssignments" = true, then it is inheriting permission from the site, so it will show all RoleAssignments for the site.

PNP Module version info:

Name: SharePointPnPPowerShell2016 Version: 3.24.2008.1

to see this info on your PowerShell just run:

Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM