Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

As the title says I need to find/write a Powershell script that will look through all of my Site Collection to see where a specific (custom) Permissions Level is being used.

All the articles I have found are about creating or editing permission levels with Powershell.

Thanks mtwelve

share|improve this question
add comment

2 Answers 2

There is a similar script on technet forums:

#$path = get-location
$sites = get-spsite "http://SP2010/site/sam/"
foreach ($site in $sites)
 {

    write-host -foregroundcolor green "Working on Site Collection: "$site.RootWeb.Title "..."
    foreach ($web in $site.AllWebs)
     {
      foreach($roleAssignment in $web.RoleAssignments)
      {
 write-host -foregroundcolor green "Group Name: "$roleAssignment.Member.Name "..."

           foreach($roleDefinition in $roleAssignment.RoleDefinitionBindings)
                {
                    write-host -foregroundcolor red "Permission Name: "$roleDefinition.Name "..."
                }

      }

     }
      $web.Dispose()
 }


$site.Dispose()

You can modify this script to check the role instead of just print it out.

SOURCE

share|improve this answer
add comment
#Add SharePoint PowerShell SnapIn if not already added
 if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) {
 Add-PSSnapin "Microsoft.SharePoint.PowerShell"
 } 

#Define variables
 $site = Get-SPSite "http://sitecoll"

#Get all subsites for site collection
 $web = $site.AllWebs

#Loop through each subsite and write permissions

foreach ($web in $web)
 {
 if (($web.permissions -ne $null) -and ($web.hasuniqueroleassignments -eq "True"))
 {
 Write-Output "****************************************"
 Write-Output "Displaying site permissions for: $web"
 $web.roledefinitions | fl Name
 }

#Loop through each list in each subsite and get permissions

foreach ($list in $web.lists)
 {
 $unique = $list.hasuniqueroleassignments
 if (($list.permissions -ne $null) -and ($unique -eq "True"))
 {
 Write-Output "****************************************"
 Write-Output "Displaying Lists permissions for: $web \ $list"
 $list.roleassignments | fl roledefinitionbindings
 }
 }
 }
 Write-Host "Finished."
 $site.dispose()
 $web.dispose()

Run it as

 C:>./script.ps1 | out-file C:/permissions.txt

Then you CTRL+F search for the definition you are looking for.

I modified this script from here

share|improve this answer
    
He may also need to loop through items in each list as well. –  Nadeem Yousuf Jan 23 '13 at 16:25
    
ah, didn't think of that. thanks. –  Mike Jan 23 '13 at 16:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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