导出某个目录下所有文件夹权限,每个目录权限对应一个csv文件
$sfolder = "D:FileSharefinance dep" $folders = gci $sfolder -Recurse | ? {$_.Mode -eq "d----"} $rfolder = "D:OperationsScriptsfinance-p" foreach ($folder in $folders) { $f = $folder.fullname $acls = Get-Acl $f |select * $foldernamer = $acls.Path.Split("::")[3].replace("","-") $foldername = $foldernamer.substring(1,$foldernamer.length-1) + ".csv" $folderpath = Join-Path $rfolder $foldername foreach($p in $acls.Accesstostring.split("`n")) { if($p.Contains("UXIN") -and (!$p.contains("Admin"))) { $ps = $p.Split(" ") $pcount = $p.Split(" ").length $ps[0] + "," + $ps[1..($pcount-1)] -join " " |Out-File $folderpath -Encoding UTF8 -Append } } }