Friday, May 26, 2017

ACL (Access Control List) Powershell Script

This script will provide you all the information about the complete folder access information
##############################################################################


$Objec = New-Object -TypeName PSObject

$Path = \\networkpath\ # Please change the path according to your requiremant

$Folders = Get-ChildItem -Path $path -recurse | where {$_.psiscontainer}
 
    Foreach ($Folder in $Folders)
     {
    

       
    $ACLs = get-acl $Folder.FullName | ForEach-Object {$_.Access}
   
Foreach ($ACL in $ACLs)
{


        # $Objec | Add-Member -MemberType NoteProperty -Name Server -Value $FileServer -Force
        $Objec | Add-Member -MemberType NoteProperty -Name Path -Value $Folder.FullName -Force
        $Objec | Add-Member -MemberType NoteProperty -Name IdentityReference -Value $ACL.IdentityReference -Force
        $Objec | Add-Member -MemberType NoteProperty -Name FileSystemRights -Value $ACL.FileSystemRights -Force
        $Objec | Add-Member -MemberType NoteProperty -Name AccessControlType -Value $ACL.AccessControlType -Force
        $Objec | Add-Member -MemberType NoteProperty -Name IsInherited -Value $ACL.IsInherited -Force
        $Objec | Add-Member -MemberType NoteProperty -Name InheritanceFlags -Value $ACL.InheritanceFlags -Force
        $Objec | Add-Member -MemberType NoteProperty -Name PropagationFlags -Value $ACL.PropagationFlags -Force
       
        $ACL.FullName
        
         $objec | Export-Csv C:\Temp\ACLInfo_L186SR20_L186_28thApril.csv -Encoding UTF8 -append -NoTypeInformation -Force

         }
      }

Write-Host -ForegroundColor Yellow "For any query related to it please leave a message on the blog, Will try to clarify your lacuna soon=====Thanks"

No comments:

Test Script

############################################################################## #####################################################...