Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getACLS ([string]$path, [int]$max, [int]$current)
- {
- $dirs = Get-ChildItem -Path $path | Where { ($_.psIsContainer) }
- $acls = Get-Acl -Path $path
- $SECURITY = @()
- $i = 0
- #Places the Security attributes in $security array
- foreach ($acl in $acls.Access)
- {
- if (($acl.identityreference -like "DOMAIN\*") <#-and ($acl.accesscontroltype -eq "allow")#> -and ($acl.IsInherited -eq 0))
- {
- $Security += "%" + $dir.FullName + '%' + $acl.identityreference + '%' + $acl.FileSystemRights + '%' + $acl.AccessControlType
- $i++
- }
- }
- if ($current -lt $max) {
- if ($dirs) {
- foreach ($dir in $dirs) {
- $newPath = $dir.FullName
- getACLS $newPath $max ($current+1)
- }
- }
- } elseif ($current -eq $max ) {
- return ($Security)
- }
- }
- $Path = "C:\"
- $Max = 2
- $current = 0
- $Array = @()
- while($Max -gt $current)
- {
- $test += GetAcls $Path $Max $current
- $Max--
- }
- $i = 0
- $Hash = New-Object System.Object
- foreach($line in $test)
- {
- $temp = $line.Split('%')
- $Hash = New-Object System.Object
- $Hash | Add-Member -type NoteProperty -name Directory -value $temp[1]
- $Hash | Add-Member -type NoteProperty -name Group -value $temp[2]
- $Hash | Add-Member -type NoteProperty -name Rights -value $temp[3]
- $Hash | Add-Member -type NoteProperty -name Access -value $temp[4]
- $array += $Hash
- }
Add Comment
Please, Sign In to add comment