1

Have this code

function GetChildFolders($RootFolder)                       
{                        
    if($count -ne 1){                        
    $folderName=$folderName+'\'+$RootFolder.Name                        
    }                        
    $Context.Load($RootFolder)                        
    $Context.Load($RootFolder.Folders)                        
    $Context.ExecuteQuery()                        
    $count++                        

    if($folderName -eq $FolderRelativePath){                        

        $group = $Context.web.SiteGroups[$groupAD];                           
        $RootFolder.BreakRoleInheritance($false);                        
        $roleAssignment = New-Object microsoft.sharepoint.SPRoleAssignment($group);                        
        $roleDefinition = $Context.web.RoleDefinitions[$permission];                        
        $roleAssignment.RoleDefinitionBindings.Add($roleDefinition);                           
        $spFolder.RoleAssignments.Add($roleAssignment);                               
        $spFolder.Update();                         
    }                        

    foreach($folder in $RootFolder.Folders)                        
    {                        

    GetChildFolders $folder                          

    }                        

}                        
GetChildFolders $List.RootFolder                        
$count = 1                                                

This goes through all of the folders in my document library and if it matches a string (with a name of a folder in) it changes the permissions of that folder.

However I get an error saying

[Microsoft.SharePoint.Client.Folder] does not contain a method named BreakRoleInheritance.

What am I doing wrong?

1 Answer 1

0

Microsoft.sharepoint.client.folder does not have property for BreakRoleInheritance

Update your code with below.

$RootFolder.ListItemAllFields.BreakRoleInheritance($true,$false)

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.