We have a SharePoint which uses claims based authentication. I need to iterate through all files in library using PowerShell and share the each with a particular claim.

Could you please help me to to figure our how can I add a claim as a user/group in PowerShell considering the following scripts:

Add-PSSnapin Microsoft.SharePoint.PowerShell 
$url = "http://mysite"
$listName = "mylist"
$permissionLevel = "read"
$groupName = "c:0-.f|rolesprovider|claim"
$web = Get-SPWeb $url
$list = $web.Lists[$listName]
$group = $web.EnsureUser($groupName) #Exception calling "EnsureUser" with "1" argument(s): "The specified user could not be found."
$role = $web.RoleDefinitions[$permissionLevel]
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($group)
foreach ($item in $list.Items) {

1 Answer 1


See Programmatically granting permissions to claims

  • The article is useful, but the question was about how to do this with PowerShell... Can you improve your answer adding a relevant code sample? It will also be better than just referencing external site.
    – Egor
    Commented Oct 17, 2017 at 13:11

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.