您好,
乱码的话可以改文件编码,不需要的属性可以直接去掉,但权限的显示是没有办法改变顺序的。
二级目录
$path = "\\192.168.135.130\test\"
$result = "C:\temp\level2result.csv"
[console]::InputEncoding = [System.Text.Encoding]::UTF8
[console]::OutputEncoding = [System.Text.Encoding]::UTF8
if(Test-Path -Path $result){ Remove-Item -Path $result}
$dirs = Get-ChildItem $path -Directory
foreach($dir in $dirs){
(Get-Acl -Path $dir.fullname).Access | ForEach-Object{
$_ | Select-Object @{n="Folder";e={$dir.fullname}},IdentityReference,FileSystemRights,IsInherited
} | Export-Csv -Path $result -NoTypeInformation -Append -Encoding UTF8
}
Import-Csv -Path $result -Encoding UTF8 | Format-Table
三级目录
$path = "\\192.168.135.130\test\"
$result = "C:\temp\level3result.csv"
[console]::InputEncoding = [System.Text.Encoding]::UTF8
[console]::OutputEncoding = [System.Text.Encoding]::UTF8
if(Test-Path -Path $result){ Remove-Item -Path $result}
$dirs = Get-ChildItem $path -Directory | Get-ChildItem -Directory
foreach($dir in $dirs){
(Get-Acl -Path $dir.fullname).Access | ForEach-Object{
$_ | Select-Object @{n="Folder";e={$dir.fullname}},IdentityReference,FileSystemRights,IsInherited
} | Export-Csv -Path $result -NoTypeInformation -Append -Encoding UTF8
}
Import-Csv -Path $result -Encoding UTF8 | Format-Table
二级和三级目录
$path = "\\192.168.135.130\test\"
$result = "C:\temp\level23result.csv"
[console]::InputEncoding = [System.Text.Encoding]::UTF8
[console]::OutputEncoding = [System.Text.Encoding]::UTF8
if(Test-Path -Path $result){ Remove-Item -Path $result}
$dirs = Get-ChildItem $path -Directory -Depth 1
foreach($dir in $dirs){
(Get-Acl -Path $dir.fullname).Access | ForEach-Object{
$_ | Select-Object @{n="Folder";e={$dir.fullname}},IdentityReference,FileSystemRights,IsInherited
} | Export-Csv -Path $result -NoTypeInformation -Append -Encoding UTF8
}
Import-Csv -Path $result -Encoding UTF8 | Format-Table
如您还有其他疑问,请随时与我们联系。如果回答是有帮助的,请将其标记为答案,可以帮助其他有相同问题的社区成员快速找到有用的答复
祝好
Ian Xue
Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.