So to reduce my burden i wrote a script which gives me a list of all folder which have not inheriting from their parent folder.
I kept one thing under consideration while writing it. When we disable inheritance from any folder we keep Administrator with Full Control to manage the folders. You can make the change if you use any other group or service account for the same.
Script
$path = "\\path\to\the\folder"
$dir = Get-ChildItem -Path $path -Recurse -ErrorAction SilentlyContinue
foreach ($line in $dir)
{
$type = $line | Select-Object -Property Attributes -ExpandProperty Attributes
if ($type -eq 'Directory')
{
$folders = $line.FullName
foreach ($folder in $folders)
{
$access = Get-Acl $folder | Select-Object -Property Access -ExpandProperty Access
foreach ($info in $access)
{
if ($info.IdentityReference -eq "BUILTIN\Administrators")
{
$inher = $info.IsInherited
if ($inher -eq $false)
{
Write-Host $folder
}
}
}
}
}
}
0 comments:
Post a Comment