获取文件所有者/作者 [英] Get File Owner/Author
本文介绍了获取文件所有者/作者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下脚本从 C: 驱动器检索特定文件类型并将特定文件属性输出到分隔的 CSV 文件.我还希望能够检索文件所有者和作者.非常感谢任何帮助.
I have the below script retrieving specific file types from the C: drive and outputting specific file properties to a delimited CSV file. I would like to be able to also retrieve the file owner and authors. Any help is very much appreciated.
# PowerShell script to list the .xlsx files under the C Drive
$Dir = get-childitem "C:" -recurse -force
$List = $Dir | where {$_.extension -eq ".xlsx"}
$List |Select-Object fullname, LastAccessTime, LastWriteTime, CreationTime |Export-Csv -path C:\Scripts\xlsx.csv -NoTypeInformation
推荐答案
当我发布这篇文章时,我就找到了解决方案.我将 @{N='Owner';E={$_.GetAccessControl().Owner}}
添加到选择对象字符串中.现在看起来像这样:
As soon as I posted this I was able to find a solution. I added @{N='Owner';E={$_.GetAccessControl().Owner}}
to the select-object string. It now looks like this:
$List | Select-Object fullname, LastAccessTime, LastWriteTime, CreationTime, @{N='Owner';E={$_.GetAccessControl().Owner}} | Export-Csv -path C:\Scripts\xlsx.csv -NoTypeInformation
这篇关于获取文件所有者/作者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文