this PowerShell script allows for resetting the permissions with broken inheritance within a SharePoint 2010 site collection. It will run through all subsites, lists, document libraries, folders and individual items, check if permission inheritance is broken and reset the inheritance.
The script has been tested on SharePoint Server 2010.
Usage:
- Start SharePoint 2010 Management Shell (PowerShell)
- execute ./Reset-BrokenInheritance.ps1 http://sites.contoso.com/sites/SiteCollectionA
PowerShell
Edit|Remove
Function ResetWebPermissionInheritance($web) 
{ 
    foreach ($subweb in $web.Webs) 
    { 
         ResetWebPermissionInheritance($subweb) 
    } 
    foreach ($list in $web.Lists) 
    { 
        ResetListPermissionInheritance($list) 
    } 
    if ($web.HasUniqueRoleAssignments) 
    { 
        Write-Host "Resetting inheritance on WEB:" $web.Url   
        $web.ResetRoleInheritance() 
        $web.Update() 
    } 
} 
Function ResetListPermissionInheritance($list) 
{ 
    #reset list items => files 
    foreach($item in $list.Items) 
    { 
        if ($item.HasUniqueRoleAssignments) 
        { 
            Write-Host "Resetting inheritance on LISTITEM:" $item.Url   
            $item.ResetRoleInheritance()  
            $item.Update() 
        } 
    } 
     
    #reset list folders => folders 
    foreach ($folder in $list.Folders) {  
        if ($folder.HasUniqueRoleAssignments) 
        { 
            Write-Host "Resetting inheritance on LISTFOLDER:" $folder.Url   
            $folder.ResetRoleInheritance()  
            $folder.Update() 
        } 
    } 
    #reset the list itself 
    if ($list.HasUniqueRoleAssignments) 
    { 
        Write-Host "Resetting inheritance on LIST:" $list.Url   
        $list.ResetRoleInheritance()  
        $list.Update() 
    } 
} 
 
 
$a = $args.length 
if ($a -eq 0) { Write-warning "You must supply a site collection URL"break} 
 
$siteCollection = Get-SPSite $args[0] 
foreach($spWeb in $siteCollection.AllWebs) 
{ 
    if (!$spWeb.IsRootWeb)   
    {     
        ResetWebPermissionInheritance($spWeb) 
    } 
}     
$spWeb.Dispose() 
$siteCollection.Dispose()