仅使用3个级别的子文件夹来获取文件夹权限

时间:2020-05-20 13:19:21

标签: windows powershell directory permissions

首先:对不起,我的英语不好。

因此,我需要创建具有指定文件夹所有权限的各种报告。 经过一番搜索,我发现了两种方法。 一种是使用AccessEnum,它几乎是完美的,但是它不会导出所有权限,只会导出权限与根文件夹不同的文件夹。而且我需要所有这些,即使它们与根文件夹相同。

第二个更好,一个Powershell脚本,但有一个缺点:递归过多,其中一个文件夹的输出报告为7GB。神圣的衬衫。

我需要什么:将脚本修改为仅对3个级别的子文件夹更深入,例如: “ C:\ Folder1”包含各种子文件夹,但我希望脚本仅深入到“ C:\ Folder1 \ Folder2 \ Folder3 \”

我该怎么办?

这是脚本:

dir -Recurse "C:\FOLDER" | where { $_.PsIsContainer } | % { $path1 = $_.fullname; Get-Acl $_.Fullname | % { $_.access | Add-Member -MemberType NoteProperty '.\Application Data' -Value $path1 -passthru }} | Export-Csv "C:\REPORT.csv"

1 个答案:

答案 0 :(得分:0)

使用

Get-Childitem

相反。它具有深度参数,并且您只能包含文件夹。

参考: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem?view=powershell-7