Powershell script to display unique permissions for all subsites and lists
Requirement
Display security permissions for site collection, subsites, and lists/libraries in each site.
Solution
This can be achieved by a simple powershell script. To use it, you must modify the $site variable to point to your site collection.
Syntax: <script name>.ps1 | out-file c:\permissions.txt
#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://<site collection>"
#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.permissions | fl member, basepermissions
}
elseif ($web.hasuniqueroleassignments -ne "True")
{
Write-Output "****************************************"
Write-Output "Displaying site permissions for: $web"
"$web inherits permissions from $site"
}
#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.permissions | fl member, basepermissions
}
elseif ($unique -ne "True") {
Write-Output "$web \ $list inherits permissions from $web"
}
}
}
Write-Host "Finished."
$site.dispose()
$web.dispose()
$unique.dispose()
The output you get will look something like this:
****************************************
Displaying site permissions for: Intranet
Member : domain\administrator
BasePermissions : ViewFormPages, Open, BrowseUserInfo, UseClientIntegration, Us
eRemoteAPIs
Intranet \ Brands inherits permissions from Intranet
Intranet \ Content and Structure Reports inherits permissions from Intranet
****************************************
Displaying Lists permissions for: Intranet \ News
Member : domain\domain users
BasePermissions : ViewListItems, OpenItems, ViewVersions, ViewFormPages, Open,
ViewPages, CreateSSCSite, BrowseUserInfo, UseClientIntegratio
n, UseRemoteAPIs, CreateAlerts
Intranet \ Pages inherits permissions from Intranet
Intranet \ PDFs inherits permissions from Intranet
****************************************
Displaying site permissions for: About Company
About Company inherits permissions from SPSite Url=http://my.company/intranet
About Company \ Documents inherits permissions from About Company
Displaying Lists permissions for: About Company\ Images
Member : domain\administrator
BasePermissions : ViewFormPages, Open, BrowseUserInfo, UseClientIntegration, Us
eRemoteAPIs
As you can see, the script only displays the permissions of subsites and lists that are unique.
2 Responses to Powershell script to display unique permissions for all subsites and lists
Categories
Recent Posts
- Save document library as template option not available
- Short break
- Speed up SharePoint using the IIS Blobcache
- Could not generate mail report.An exception occurred while executing a Transact-SQL statement or batch.No global profile is configured. Specify a profile name in the @profile_name parameter.
- Microsoft SharePoint is not supported with version 4.0.30319.296 of the Microsoft .Net Runtime.
Popular Posts
- SharePoint Keeps Prompting for Credentials Problem SharePoint keeps prompting you for credentials in the following scenarios: You ...
- Security Token Service Application- Broken Problem Had an issue today on one of my developer's VMs. ...
- User Profile Service Stuck on Starting Problem You have followed Harbar's Rational Guide to setting up the ...
- Event 8313 Topology – Load Balancer EndpointFailure – SearchService.svc Problem Encountered the following error while analysing the logs on our ...
- Event 6398 and 5586 SharePoint Foundation Problem Event logs were getting filled with the following errors: Event 5586, ...
- The security validation for this page is invalid Problem: After applying SharePoint 2010 Service Pack 1 and June 2011 ...
- The local farm is not accessible. Cmdlets with FeatureDependencyId are not registered. Problem You install .NET Framework 4.0 on your SharePoint 2010 WFE ...
- Start a workflow using PowerShell Requirement Start a workflow on all / specific items in a ...
- Using Export-SPWeb to export libraries / lists This is a simple one but many people get the ...
- Unable to change User Profile Service Account Problem So you made a mistake by trying to change the ...
Tags
Backup and Restore Branding Content Management Content Organizer database Debugging Document Conversion Service DPM Event 7362 Expiration Policy IIS InfoPath Information Management Javascript KB2266203 Masterpage Migration Mysite OCS Office Page Layouts PowerPivot Powershell RBS Records Center Regional Settings Search Search Center Security Send-to Connection SharePoint Diagnostic Studio SharePoint Manager Solutions SPD Uploading Usage and Health Data Collection User Profile Service Visual Upgrade Web Analytics Web Content Management Webdav Webparts Workflow WSS XSLT

thanks for the hints!
Code Markup for wordpress will help posted code not bleed outside your posts.
http://thunderguy.com/semicolon/wordpress/code-markup-wordpress-plugin/
Hey, thanks for the tip too
Fixed!