4

I want to generate a report of every document and permissions on it. Permissions contains General Permission and Users who have permission through a sharing link/ or external sharing link. When I run a code I get a result like "SharingLinks.fdbe4441-98ec-47f5-9795-78f8e6e826e9.OrganizationEdit.00e9b96f-8eb7-4a68-b162-f7accc9fec66 : Contribute" It means this document has been shared with Sharing Link having Contribute permission. Please see the Image below. It shows all the users having permission. But how can I get this info using Powershell script (PnP-Powershell) user permissions

2
  • Looking for a similar approach. All I can think so far is to grab all the items in a list and filter by the ones which has unique accessrules defined
    – Alberto S.
    Dec 26, 2019 at 13:06
  • Did you manage to get PowerShell for your requirement? I have the same requirement and coudnt find any script
    – George
    Jun 4, 2020 at 14:35

1 Answer 1

0
#$fileUrl -NewFolder/logo.png
$file = Get-PnPFile -Url $fileUrl -AsListItem

Get-PnPProperty -ClientObject $file -Property RoleAssignments
$members = Get-PnPProperty -ClientObject $roleAssignments -Property RoleDefinitionBindings, Member
$member = $roleAssignments.Member 
#list of users 
$Users = Get-PnPProperty -ErrorAction SilentlyContinue -ClientObject $member -Property Users 
#Return Accesstype
$accessType = $roleAssignments.RoleDefinitionBindings.Name;
   if ($member.Title -like "SharingLinks*") {
            if ($Users -ne $null) {
                $array = foreach ($user in $Users) {
                Write-host $user.LoginName, $accessType
                }
           }
    }

Your Answer

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

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