Bladeren bron

add recursion to effective access

Tobias Simetsreiter 2 jaren geleden
bovenliggende
commit
0d08582f6c
2 gewijzigde bestanden met toevoegingen van 28 en 15 verwijderingen
  1. 0 15
      bin/Get-EffectiveAccess.ps1
  2. 28 0
      bin/Get-EffectiveAccessRecurse.ps1

+ 0 - 15
bin/Get-EffectiveAccess.ps1

@@ -1,15 +0,0 @@
-param(
-    $Path,
-    $Account
-)
-
-foreach ($module in @("NTFSSecurity")){
-    if (-not (Get-Module -ListAvailable -Name $module)) {
-        Install-Module $module -Scope CurrentUser
-    }
-    if (-not (Get-Module $module)) {
-        Import-Module  $module
-    }
-}
-
-Get-NTFSEffectiveAccess -Account $Account -Path $Path

+ 28 - 0
bin/Get-EffectiveAccessRecurse.ps1

@@ -0,0 +1,28 @@
+param(
+    $Path,
+    $Account,
+    [Int]
+    $Depth=99
+)
+
+foreach ($module in @("NTFSSecurity")){
+    if (-not (Get-Module -ListAvailable -Name $module)) {
+        Install-Module $module -Scope CurrentUser
+    }
+    if (-not (Get-Module $module)) {
+        Import-Module  $module
+    }
+}
+
+Get-ChildItem -Recurse -Depth $Depth -Directory $path | ForEach-Object {
+    $rights = Get-NTFSEffectiveAccess -Account $Account -Path $_.FullName
+    [PSCustomObject]@{
+        Path=$_.FullName
+        AccessRights=$rights.AccessRights
+        InheritanceFlags=$rights.InheritanceFlags
+        AccessControlType=$rights.AccessControlType
+        InheritedFrom=$rights.InheritedFrom
+        InheritanceEnabled=$rights.InheritanceEnabled
+        Account=$Account
+    }
+}