About Me

My photo
HANUMANGARH, RAJASTHAN, India

Monday 29 August 2022

Get Folder ACL Level wise

 $rFolder = Get-Content C:\Users\su-skumar\Desktop\ser.txt

[int]$recursionDepth = Read-Host -Prompt "Enter recursion depth"

[string]$outputCsv = Read-Host -Prompt "Enter output .csv file (full path)"

[string]$recursionStr = if ($recursionDepth -eq 0) { "\*" } else { ("\*" * ($recursionDepth + 1)) }

foreach ($rootFolder in $rFolder){

$folders = Get-ChildItem -Directory -Path "$rootFolder$recursionStr" -Force | Where-Object { $_.PSIsContainer -eq $true }

[array]$report = @()


foreach ($folder in $folders) {

    $acl = Get-Acl -Path $folder.FullName

    foreach ($access in $acl.access) {

        [hashtable]$properties = [ordered]@{

            'FolderName'       = $folder.FullName;

            'AD Group or User' = $access.IdentityReference;

            'Permissions'      = $access.FileSystemRights;

            'Inherited'        = $access.IsInherited

        }

        $report += New-Object -TypeName PSObject -Property $properties

    }

}

Write-Host $report

$report | Export-Csv -Path $outputCsv -Append


}

No comments:

Post a Comment

Export contact from Justdial

  Extract Data From JustDial using Selenium Let us see how to extract data from Justdial using Selenium and Python. Justdial is a company th...