瀏覽代碼

add recursion to effective access

Tobias Simetsreiter 2 年之前
父節點
當前提交
0d08582f6c
共有 2 個文件被更改,包括 28 次插入15 次删除
  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
+    }
+}