2

I am new to SharePoint and am writing PowerShell scripts to create a number of libraries. Each library will be added as a list webpart on a webpart page for added security. Finally, the page is added to navigation. I have been able to write the code for creating the libraries, pages and the navigation and added security to both the navigation and the library. So, users without access to certain pages will not be able to see the navigation and the library. However, if someone has a link to the page, they will be able to go directly to the page without using the navigation.

Can someone please point me in the right direction so I can add security to the pages as well or is it even possible?

2

If the page is in a list, you could probably reuse your code setting permissions on the library. Access you list like and set unique permissions, like the following:

$site = Get-SPSite("http://SiteUrl")
$web = $site.RootWeb
$list = $web.Lists["Site Pages"]
$listitem = $list.Items[0]

if($listitem.HasUniqueRoleAssignments -eq $false) 
{
    $listitem.BreakRoleInheritance($true)
}

$listitem.Update()
1
  • Thanks for that. But I was wondering how to set the security if I already have the page object. If there is no way to set it with the already secured page object, then I guess I'll try your solution.
    – Divi
    Mar 13 '13 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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