Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $FolderToBreak = "/sitename/Documents/testtt123"
- $userToRemove = "user@domain.com"
- ##Variables for Processing
- $SiteUrl = "https://sitename.sharepoint.com/sitename"
- $UserName="globaladmin@domain.com.au"
- $Password ="xxxxxx"
- Add-Type -Path "c:CSOMMicrosoft.SharePoint.Client.dll"
- Add-Type -Path "c:CSOMMicrosoft.SharePoint.Client.Runtime.dll"
- #Setup Credentials to connect
- $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))
- Try {
- #Set up the context
- $Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
- $Context.Credentials = $credentials
- #Get the List Root Folder
- $Folder=$Context.web.GetFolderByServerRelativeUrl($FolderToBreak)
- #break inheritance just incase, should already be broken to share user to begin with
- $Folder.ListItemAllFields.BreakRoleInheritance($true,$false)
- #want to remove permission from the user $userToRemove from $folder but roleassignements doesnt have a .remove, and now i am lost....
- $Folder.ListItemAllFields.RoleAssignments....
- }
- catch {
- write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
- }
Add Comment
Please, Sign In to add comment