Share via


Manage Item permission Via powershell

Question

Monday, July 8, 2013 7:33 AM

Hi

I need add read permission for all authenticated users in the list item. The list item are in unique level permission. how can i add the read permission for all the item using powershell

Ravin Singh D

All replies (5)

Monday, July 8, 2013 12:55 PM âś…Answered

Man, just replace group name in script:

$visitorsSPGroup ="NT AUTHORITY\authenticated users" 

 

Best regards, Andrii


Monday, July 8, 2013 7:39 AM

Hi,

Using power shell loop through all the items in your library and then add domain\ntauthenticated users group to each of the item with read permission level

Thanks Santhosh V


Monday, July 8, 2013 10:47 AM

Hi,

Below code will add "Contribution" permission to a list, you can use it with a little customization.

# Alter Item-Level Permission settings and assign "Contribute" role definition to the visitors group
# (c) 2011 Morgan de Jonge
 
# Specify the name of the visitors SharePoint group
$visitorsSPGroupName = "Example Site Visitors"
 
$spSite = Get-SPSite "http://portal.contoso.com"
# We'll assume the list is in the top-level site in the site collection
$spWeb = $spSite | Get-SPWeb
# Look up the list named "Questions"
$questionsList = $spWeb.Lists["Questions"]
 
# Set the Read access Item-level permissions settings to "Read items that were created by the user"
$questionsList.ReadSecurity = 2
# Set the Create and Edit access Item-level permissions to "Create items and edit items that were created by the user
$questionsList.WriteSecurity = 2
 
# Assign the "Contribute" RoleDefition to the site's visitors group
$visitorsSPGroup = $spWeb.Groups[$visitorsSPGroupName]
$questionsList.BreakRoleInheritance($true)
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($visitorsSPGroup)
# Assuming this is a default site, we'll look for a role definition of the type "Contributer".
# This way, the script will also work with SharePoint sites created in languages besides English.
$assignment.RoleDefinitionBindings.Add(($spWeb.RoleDefinitions | Where-Object { $_.Type -eq "Contributor" }))
$questionsList.RoleAssignments.Add($assignment)
 
$questionsList.Update()
 
$spWeb.Dispose()
$spSite.Dispose()

Thanks,

Kenon Yin


Monday, July 8, 2013 12:19 PM

Hi

The code assign permission to the specific group. I want to the same for the all authenticated users

Ravin Singh D


Monday, July 8, 2013 12:20 PM

Can you send me example code

Ravin Singh D