@@ -45,6 +45,18 @@ function Idm-SystemInfo {
4545 label = ' Recursive'
4646 value = ' true'
4747 }
48+ @ {
49+ name = ' ignoreACEPermissionErrors'
50+ type = ' checkbox'
51+ label = ' Ignore ACE Permission Errors'
52+ value = ' false'
53+ }
54+ @ {
55+ name = ' skipFolderACL'
56+ type = ' checkbox'
57+ label = ' Skip Folder ACL'' s'
58+ value = ' false'
59+ }
4860 )
4961 }
5062
@@ -309,6 +321,7 @@ function Idm-ExplicitACEsRead {
309321 $out = New-Object System.Collections.ArrayList
310322
311323 foreach ($path_spec in $system_params.paths_spec ) {
324+ Log debug " Path: $ ( $path_spec.path ) "
312325 $gci_args = @ {
313326 Directory = $true
314327 Force = $true
@@ -340,10 +353,8 @@ function Idm-ExplicitACEsRead {
340353 # For directories, GetAccessControl() returns [System.Security.AccessControl.DirectorySecurity],
341354 # which is the same as Get-Acl returns.
342355 $sd = $_.GetAccessControl ()
343-
344356 # GetAccessRules() returns [System.Security.AccessControl.FileSystemAccessRule]
345357 $acl = $sd.GetAccessRules ($true , $false , $system_params.principal_type ) # includeExplicit, !includeInherited
346-
347358 $ix = 0
348359
349360 $acl | ForEach-Object {
@@ -363,8 +374,14 @@ function Idm-ExplicitACEsRead {
363374 }
364375 }
365376 catch {
366- Log error " Failed: $_ "
367- Write-Error $_
377+ if ($system_params.ignoreACEPermissionErrors )
378+ {
379+ Log warning " Failed: $_ "
380+ Write-Warning $_
381+ } else {
382+ Log error " Failed: $_ "
383+ Write-Error $_
384+ }
368385 }
369386 }
370387
@@ -477,6 +494,7 @@ function Idm-FoldersRead {
477494 $access_profiles = GetAccessProfiles $system_params $function_params
478495
479496 foreach ($path_spec in $system_params.paths_spec ) {
497+ Log debug " Path: $ ( $path_spec.path ) "
480498 $path_with_backslash = AppendBackslashToPath $path_spec.path
481499
482500 $gci_args = @ {
@@ -498,7 +516,7 @@ function Idm-FoldersRead {
498516 # "Cannot find drive. A drive with the name 'x' does not exist" instead of
499517 # "A parameter cannot be found that matches parameter name 'Directory'".
500518 Get-ChildItem - Force - LiteralPath $path_spec.path > $null
501-
519+
502520 # For directories, Get-ChildItem returns [System.IO.DirectoryInfo]
503521 Get-ChildItem @gci_args | ForEach-Object {
504522 foreach ($exclude in $system_params.excludes ) {
@@ -509,18 +527,28 @@ function Idm-FoldersRead {
509527 } | ForEach-Object {
510528 # For directories, GetAccessControl() returns [System.Security.AccessControl.DirectorySecurity],
511529 # which is the same as Get-Acl returns.
512- $sd = $_.GetAccessControl ()
530+ if ($system_params.skipFolderACL ) {
531+ $ht = @ {
532+ Attributes = ($_.Attributes -split ' ,' | ForEach-Object { $h = $_.Trim (); if ($h.Length -gt 0 ) { $h.Substring (0 , 1 ).Toupper() } }) -join ' '
533+ Depth = $_.FullName.Substring ($path_with_backslash.length ).Split(' \' ).Count - 1
534+ InheritanceEnable = ' '
535+ Owner = ' '
536+ Path = $_.FullName.Substring (0 , $_.FullName.length - $_.Name.Length )
537+ }
538+ } else {
539+ $sd = $_.GetAccessControl ()
540+
541+ $ht = @ {
542+ Attributes = ($_.Attributes -split ' ,' | ForEach-Object { $h = $_.Trim (); if ($h.Length -gt 0 ) { $h.Substring (0 , 1 ).Toupper() } }) -join ' '
543+ Depth = $_.FullName.Substring ($path_with_backslash.length ).Split(' \' ).Count - 1
544+ InheritanceEnable = $sd.AreAccessRulesProtected -eq $false
545+ Owner = $sd.GetOwner ($system_params.principal_type ).Value
546+ Path = $_.FullName.Substring (0 , $_.FullName.length - $_.Name.Length )
547+ }
513548
514- $ht = @ {
515- Attributes = ($_.Attributes -split ' ,' | ForEach-Object { $h = $_.Trim (); if ($h.Length -gt 0 ) { $h.Substring (0 , 1 ).Toupper() } }) -join ' '
516- Depth = $_.FullName.Substring ($path_with_backslash.length ).Split(' \' ).Count - 1
517- InheritanceEnable = $sd.AreAccessRulesProtected -eq $false
518- Owner = $sd.GetOwner ($system_params.principal_type ).Value
519- Path = $_.FullName.Substring (0 , $_.FullName.length - $_.Name.Length )
549+ $ht += GetIdentityReferencesMatchingAccessProfiles $sd $access_profiles $system_params.principal_type
520550 }
521-
522- $ht += GetIdentityReferencesMatchingAccessProfiles $sd $access_profiles $system_params.principal_type
523-
551+
524552 $_ | Add-Member - PassThru - Force - NotePropertyMembers $ht
525553 } | Select-Object $function_params.properties | Sort-Object { $_.FullName }
526554 }
0 commit comments