| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | param(    $out = "runtime\acl.csv",    $base = "\\fserver.annax.local\newroot",    [Switch]    $verbose = $false,    $erroraction = "Continue")# $ErrorActionPreference = "Stop"$ErrorActionPreference = $erroractionGet-ChildItem $base -Recurse | % {    $dir = $_    try {        # $dir.FullName | out-host        $acl = Get-Acl $dir.FullName        # $acl | Out-Host        $acl.Access | Where-Object { $_.IsInherited -eq $false } | % {            $axacl = $_.IdentityReference.Value            if ($_.IdentityReference.Value -like "ANNAX\*") {                if ($verbose) {                    $axacl | Out-Host                }                $wtacl = $null                $acl.Access | Where-Object { $_.IsInherited -eq $false -and (($_.IdentityReference.Value -replace "WABTEC\\ANG_") -eq ($axacl -replace "ANNAX\\")) } | % {                    $wtacl = $_.IdentityReference.Value                }                if ($null -eq $wtacl) {                    $dir.FullName | Out-Host                    $axacl | Out-Host                    [PSCustomObject]@{                        dir = $dir.FullName                        acl = $axacl                        err = ""                    } | Export-Csv -Append $out                }                else {                    if ($verbose) {                        "MATCH" | Out-Host                        $wtacl  | Out-Host                    }                }            }        }    }    catch {        [PSCustomObject]@{            dir = $dir.FullName            acl = ""            err = $PSItem.ToString()        } | Export-Csv -Append $out    }}
 |