1

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

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

2
#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

  • He may also need to loop through items in each list as well. – Nadeem Yousuf Jan 23 '13 at 16:25

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.