
Hi @ネパリ サンデャ,
If you are using SharePoint Online, I recommend that you use SharePoint Online Management PowerShell to execute the PowerShell.
1.Download SharePoint Online Management PowerShell.
2.Open SharePoint Online Management Shell and execute the following PowerShell. Please modify the parameters at the bottom to specify your folder and report export path. Make sure you are the administrator of the site.
#Function to Get Folder Permissions
Function Get-SPOFolderPermission([String]$SiteURL, [String]$FolderRelativeURL)
{
Try{
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the Folder
$Folder = $Ctx.Web.GetFolderByServerRelativeUrl($FolderRelativeURL)
$Ctx.Load($Folder)
$Ctx.ExecuteQuery()
#Get permissions assigned to the Folder
$RoleAssignments = $Folder.ListItemAllFields.RoleAssignments
$Ctx.Load($RoleAssignments)
$Ctx.ExecuteQuery()
#Loop through each permission assigned and extract details
$PermissionCollection = @()
Foreach($RoleAssignment in $RoleAssignments)
{
$Ctx.Load($RoleAssignment.Member)
$Ctx.executeQuery()
#Get the User Type
$PermissionType = $RoleAssignment.Member.PrincipalType
#Get the Permission Levels assigned
$Ctx.Load($RoleAssignment.RoleDefinitionBindings)
$Ctx.ExecuteQuery()
$PermissionLevels = ($RoleAssignment.RoleDefinitionBindings | Select -ExpandProperty Name) -join ","
#Get the User/Group Name
$Name = $RoleAssignment.Member.Title # $RoleAssignment.Member.LoginName
#Add the Data to Object
$Permissions = New-Object PSObject
$Permissions | Add-Member NoteProperty Name($Name)
$Permissions | Add-Member NoteProperty Type($PermissionType)
$Permissions | Add-Member NoteProperty PermissionLevels($PermissionLevels)
$PermissionCollection += $Permissions
}
Return $PermissionCollection
}
Catch {
write-host -f Red "Error Getting Folder Permissions!" $_.Exception.Message
}
}
#Set Config Parameters
$SiteURL="https://yourTenant.sharepoint.com/sites/yourSite"
$FolderRelativeURL="/sites/yourSite/yourLibrary/yourFolder"
#Get Credentials to connect
$Cred= Get-Credential
#Call the function to Get Folder Permissions an export to CSV file
Get-SPOFolderPermission $SiteURL $FolderRelativeURL | Export-CSV "C:\yourPath\FolderPermissions.csv" -NoTypeInformation
Here is my test result:
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.