1
我写了一个脚本来给我一个特定路径及其所有子目录的访问ACL,并将它放在一个.txt文件中,但我需要另一种格式来创建一个数据库,使其更易于查看和访问。如何以某种格式获取FileSystemRights?
输出部分看起来是这样的:
Fullname S FileSystemRights S AccessControlType ---------- ------------------ ------------------ C:\temp ; ReadAndExecute, Synchronize ; Allow;
所以我需要输出的样子是这样的:
Fullname S FileSystemRights S AccessControlType ---------- ------------------ ------------------ C:\temp ; ReadAndExecute ; Allow; C:\temp ; Synchronize ; Allow;
正如你可以看到我需要在个人权利个别的线路,而不是堆叠在一起
什么我迄今所做的看起来是下面的,也许它可以帮助(我离开了那些不重要的东西):
(Get-Acl $TestPath).Access |
Format-Table -AutoSize -HideTableHeaders @{L="Fullname";E={$TestPath}},
@{L="S";E={";"}}, FileSystemRights,
@{L="S";E={";"}}, AccessControlType,
@{L="S";E={";"}}, IdentityReference,
@{L="S";E={";"}}, IsInherited,
@{L="S";E={";"}}, InheritanceFlags,
@{L="S";E={";"}}, PropagationFlags |
Out-File $Out -Append -Width 500
function RecDirs {
$d = $Args[0]
$AktRec++
$dirs = dir $d | where {$_.PsIsContainer}
if ($AktRec -lt 3) {
foreach($di in $dirs) {
if ($di.FullName -ne $null) {
(Get-Acl $di.Fullname).Access |
Format-Table -AutoSize -HideTableHeaders @{L="Fullname";E={$di.FullName}},
@{L="S";E={";"}}, FileSystemRights,
@{L="S";E={";"}}, AccessControlType,
@{L="S";E={";"}}, IdentityReference,
@{L="S";E={";"}}, IsInherited,
@{L="S";E={";"}}, InheritanceFlags,
@{L="S";E={";"}}, PropagationFlags |
Out-File $Out -Append -Width 500
}
RecDirs($di.Fullname)
}
}
}
RecDirs($TestPath)
看一看export-csv – guiwhatsthat