powershell - 使用 Powershell 导出 NTFS 安全权限
问题描述
使用 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/
解决方案
这在某种程度上取决于您希望导出的外观。但是,以下示例是一个起点:
$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 问题中。
但是,您可以使用带有 good-old 的替代语法Get-ChildItem
来列出长路径。这可能看起来像这样:
对于 UNC:
Get-ChildItem '\\?\UNC\<ServerName>\Share\RemainingPath' -Recurse |
...
对于本地驱动器:
Get-ChildItem '\\?\c:\temp' -Recurse |
...
推荐阅读
- c# - 用什么代替 SafeHandle.DangerousGetHandle?
- android - 如何正确滚动嵌套滚动视图?
- ios - 弹出时如何显示带有动画的标签栏?(iPhone X)
- google-app-engine - 如何在 Google 应用引擎中增加 client_max_body_size?
- liquibase - Liquibase:无法识别数据类型 CLOB
- c - 使用链表将两个多项式相乘的程序
- json - 使用复制命令将 Json 文件加载到 redshift
- javascript - 使用 echarts 图表继续强调点击
- javascript - Redux Thunk 用于简单的异步请求
- acumatica - 为什么在插入和更新新行时出现重复行?