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?