2

I'm trying to retrieve list items that have unique role assignments from a list in SharePoint Online using Get-PnpListItem, is this possible?

Currently this property is empty when using Get-PnpListItem, I can iterate over the list items and use Get-PnpProperty to retrieve this property though I thought there might be a more efficient way.

I'm looking to get the same results as you would find from _layouts/15/uniqperm.aspx on a site.

1 Answer 1

2

By list item object, it means passing the Microsoft.SharePoint.Client.ListItem object. "HasUniqueRoleAssignments" can only return by "Get-PnPProperty".

I recommend you using Get-PnPProperty to retrieve permissions for items level: Retrieve Permissions at folder and file level in Powershell

Here is an example:

$item = Get-PnPListItem -List $lib -Id $id
Get-PnPProperty -ClientObject $item -Property RoleAssignments

You may need further details about the RoleAssignments property, to do so:

Get-PnPProperty -ClientObject $item.RoleAssignments -Property Groups
        foreach ($role in $item.RoleAssignments) {
            $result = Get-PnPProperty -ClientObject $role -Property RoleDefinitionBindings, Member
        }
1
  • Whilst that works I find it is much slower than doing the same thing in C# with CSOM, see example. I haven't been able to translate the lambda ctx.Load(listItems, a => a.IncludeWithDefaultProperties(b => b.HasUniqueRoleAssignments)) in PowerShell with the PnP cmdlets.
    – mhep
    Commented Mar 25, 2019 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.