I am using PnP Powershell commands to get item level permissions(rolesassignments) if item/folder has unique permissions. But nothing working. I am always getting below error
format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It
may need to be explicitly requested.
+ CategoryInfo : NotSpecified: (:) [format-default], CollectionNotInitializedException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Commands.Form
atDefaultCommand
Code: $context = Get-PnPContext
$file = Get-PnPFolder -Url "
$context.Load($file);
$context.ExecuteQuery();
even I tried to load only roleassignments using context and even then I am getting same error
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Try this, confirmed working with 3.12.1908.1
Connect-PnPOnline -Url ""
$context = Get-PnPContext
$file = Get-PnPFolder -Url $filePath -Includes ListItemAllFields.RoleAssignments, ListItemAllFields.HasUniqueRoleAssignments
$context.Load($file);
$context.ExecuteQuery();
if($file.ListItemAllFields.HasUniqueRoleAssignments -eq $True)
{
foreach($roleAssignments in $file.ListItemAllFields.RoleAssignments)
{
Get-PnPProperty -ClientObject $roleAssignments -Property RoleDefinitionBindings, Member
$roleAssignments.Member.Title
}
}
Thank you it worked
Issue that I faced was resolved. Its small coding issue from my side :)
@garrytrinder Garry, that was working. Was just the way I had it. but in the latest versions it isn't. I Cleaned up my local versions keeping only the newest and suddenly my script broke. At that time I had only version 3.16.1912.0 running. I Tried 3.15.1911.0 which seems to be broken also. Only with a clean install of version 3.14.1910.1 I could get it to work.
Got it Working again with the latest version 3.17.2001.0 but only after a clean install of that version. i.e.
uninstall-module sharepointpnppowershellonline -AllVersions
and then a new install
Most helpful comment
Try this, confirmed working with 3.12.1908.1
Source: https://sharepoint.stackexchange.com/questions/221118/retrieve-permissions-at-folder-and-file-level-in-powershell