About Me

My photo
HANUMANGARH, RAJASTHAN, India
Showing posts with label Folder Permission. Show all posts
Showing posts with label Folder Permission. 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


}

Monday, 7 February 2022

Get Folder Permission (ACL)

 $FolderPath = dir -Directory -Path "\\sharefolder\temp" -Recurse -Force

$Report = @()

Foreach ($Folder in $FolderPath) {

    $Acl = Get-Acl -Path $Folder.FullName

    foreach ($Access in $acl.Access)

        {

            $Properties = [ordered]@{'FolderName'=$Folder.FullName;'AD

Group or

User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}

            $Report += New-Object -TypeName PSObject -Property $Properties

        }

}

$Report | Export-Csv -path "C:\ACL.csv"

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...