database - 导出更大输出的最佳格式是什么?
问题描述
我有一个大文件服务器,有一个大文件和文件夹树,我需要导出 NTFS 权限。我使用了以下脚本:
$FolderPath = Get-ChildItem -Path C:\FS -Filter * -Recurse -Force
ForEach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.FullName
ForEach ($Access in $Acl.Access) {
$Properties = [ordered]@{'Folder Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
New-Object -TypeName PSObject -Property $Properties
}
}
什么样的格式建议我从脚本中得到结果,我认为 CSV 是一种非常好的格式,但我不知道是否是正确的文件格式。
解决方案
您可以写入 CSV 格式,以后在 excel 或其他地方处理它们会更容易。
$FolderPath = Get-ChildItem -Path C:\FS -Filter * -Recurse -Force
$collection = @() #Define collection
ForEach ($Folder in $FolderPath) {
$Acl = Get-Acl -Path $Folder.FullName
ForEach ($Access in $Acl.Access) {
$Properties = [ordered]@{'Folder Name'=$Folder.FullName;'Group/User'=$Access.IdentityReference;'Permissions'=$Access.FileSystemRights;'Inherited'=$Access.IsInherited}
$collection += New-Object -TypeName PSObject -Property $Properties
}
}
$collection | Export-Csv -LiteralPath C:\ACLInformation.csv -NoTypeInformation -Encoding UTF8
推荐阅读
- python - Selenium webdriver:查找元素问题
- excel - 如果相应单元格包含“过期”一词,如何向特定收件人发送电子邮件?
- javascript - 将 WebAssembly 模块包装到 Web 组件中时出现异步问题
- android - Android Studio 北极狐 | 2020.3.1 Canary 14 找不到参数的方法 dependencyResolutionManagement()
- angularjs - 带有 AngularJS 指令的 Bootstrap 5 切换工具提示
- javascript - 如何通过异步函数创建动态href?
- protocol-buffers - “google.protobuf.Timestamp”未使用 Protobuf v2 定义
- azure - 获取模型时出错:无法在 Azure ADT 资源管理器中刷新访问令牌
- java - 如何在 Java JEditorPane 中自动将小写字母字符更新为大写字母?
- salesforce - 具有共享功能的 Salesforce Lightning 组件不起作用