I understand that you want to grant permission for the owners group to the Audit Logs library. You can use the script below:
$ownersSPGroupName = "owners"
$webUrl="http://serverURL"
$spweb = Get-SPWeb $webUrl
# Look up the list named "Audit Logs"
$questionsList = $spWeb.Lists["Audit Logs "]
# 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 owners group
$ownersSPGroup = $spWeb.Groups[$ownersSPGroupName]
$questionsList.BreakRoleInheritance($true)
$assignment = New-Object Microsoft.SharePoint.SPRoleAssignment($ownersSPGroup)
# 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()
For more information, please refer to this site:
Modifying list permissions from Powershell: http://blog.morg.nl/2011/09/modifying-list-permissions-from-powershell/
Adding permission to list using powershell: http://social.technet.microsoft.com/forums/en-US/sharepointadminprevious/thread/4373cef1-2471-4199-aa16-784684fc82de
No comments:
Post a Comment