【问题标题】:Powershell: Is there a way to enumerate access of a singular folder or file?Powershell:有没有办法枚举单个文件夹或文件的访问权限?
【发布时间】:2021-10-05 20:06:35
【问题描述】:

我向用户提出了一个问题,以披露谁有权访问特定文件夹。

我已经尝试过此脚本并获得了对文件夹的正确权限,但当前脚本包含所有子文件夹和文件并生成大量输出。

$path = "\\fs1\" #define path to the shared folder
$reportpath ="C:\temp\ACL.csv" #define path to export permissions report
#script scans for directories under shared folder and gets acl(permissions) for all of them
dir -Recurse $path | where { $_.PsIsContainer } | % { $path1 = $_.fullname; Get-Acl $_.Fullname | % { $_.access | Add-Member -MemberType NoteProperty '.\Application Data' -Value $path1 -passthru }} | Export-Csv $reportpath

我尝试在 AD 上运行单数查询,但它没有显示正确的 ACL 条目。有没有办法只查询单个文件夹/文件?像这样的查询将有助于未来的请求。

【问题讨论】:

  • 去掉dir上的-recurse开关。

标签: powershell active-directory


【解决方案1】:

感谢Santiago Squarzon 的评论。我按照您的建议进行了复制,并找到了预期的输出。

PowerShell 命令

$path = "C:\Users\" #define path to the shared folder
$reportpath ="C:\temp\ACL.txt" #define path to export permissions report
#script scans for directories under shared folder and gets acl(permissions) for all of them
dir $path | where { $_.PsIsContainer } | % { $path1 = $_.fullname; Get-Acl $_.Fullname | % { $_.access | Add-Member -MemberType NoteProperty '.\Application Data' -Value $path1 -passthru }} | Export-Csv $reportpath

输出-

【讨论】:

    猜你喜欢
    • 2020-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-02
    相关资源
    最近更新 更多