【问题标题】:Using Powershell to export the NTFS security permissions使用 Powershell 导出 NTFS 安全权限
【发布时间】:2021-05-05 23:21:56
【问题描述】:

使用 Powershell,如何获取 D: 驱动器中明确定义了所有人访问权限的文件夹列表?

我已经安装了下面的模块,但不知道如何安排命令并将其导出为 .CSV 文件。

https://ntfssecurity.readthedocs.io/en/latest/ https://devblogs.microsoft.com/scripting/weekend-scripter-use-powershell-to-get-add-and-remove-ntfs-permissions/

【问题讨论】:

    标签: powershell


    【解决方案1】:

    这在某种程度上取决于您希望导出的外观。但是,以下示例是一个起点:

    $StartPath = "C:\temp\08-28-19"
    
    Get-ChildItem $StartPath | 
    Get-NTFSAccess -Account Everyone | 
    Select-Object FullName,Account,AccessRights,Type |  
    Export-Csv c:\temp\PermExport.csv -NoTypeInformation
    

    所以你/我们可能不得不处理Select-Object 命令。请使用所需输出的示例更新问题,我们将对此进行更多讨论。

    注意:如果路径可能超过 260 个字符,则会出现一些复杂情况。 NTFSSecurity 模块包括像Get-ChildItem2 这样基于AlphaFS .Net 库的命令。但是,在命名方面存在一些错误,这些错误记录在我简要报告的 GitHub issue 中。

    但是,您可以使用带有旧 Get-ChildItem 的替代语法来列出长路径。这可能看起来像这样:

    对于 UNC:

    Get-ChildItem '\\?\UNC\<ServerName>\Share\RemainingPath' -Recurse |
    ...
    

    对于本地驱动器:

    Get-ChildItem '\\?\c:\temp' -Recurse |
    ...
    

    【讨论】:

    • 嗨@steven,是否可以在 .CSV 中导出完整路径?
    • FullName 是完整路径,可能继承自 Get-ChildItem[FileInfo][DirectoryInfo] 对象返回的 FullName 属性。
    猜你喜欢
    • 1970-01-01
    • 2014-12-20
    • 2015-06-06
    • 1970-01-01
    • 1970-01-01
    • 2015-07-15
    • 1970-01-01
    • 2015-10-23
    • 1970-01-01
    相关资源
    最近更新 更多