0

I created a folder in a SharePoint Online library.

Add-SPOFolder -Name NewFolder -Folder _catalogs/new

This works fine. But how can I give Full control permissions for a user on this folder?

1 Answer 1

1

Try to use CSOM via PowerShell to can create a Folder and assign a user permission as the following :

  • Specify the user.
$usr = $Web.EnsureUser('i:0#.f|membership|'+$email)
    Write-Host $usrRole.Description
    $clientContext.Load($usr)
    $clientContext.ExecuteQuery()
  • Define the Full control Role
$role = $web.RoleDefinitions.GetByName('Full Control')
$usrRole = New-Object Microsoft.SharePoint.Client.RoleDefinitionBindingCollection($clientContext)
$usrRole.Add($role)
$clientContext.Load($role)
$clientContext.Load($usrRole)
  • Break Inheritance, and assign the permission
$folder.ListItemAllFields.BreakRoleInheritance($false, $true)
$clientContext.Load($folder.ListItemAllFields.RoleAssignments.Add($usr, $usrRole))
$folder.Update()
$clientContext.ExecuteQuery()

Check the bundle script at SharePoint Online CSOM PowerShell Script to create folders and add permissions

Your Answer

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

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