About Me

My photo
HANUMANGARH, RAJASTHAN, India
Showing posts with label Folder ACL. Show all posts
Showing posts with label Folder ACL. Show all posts

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


}

Extract Disk Info from Remote host

 # Define the remote hostname or IP address $remoteHost = Get-Content "C:\temp\RemoteServer.txt" # Define the output CSV file path...