本文介绍了将Powershell中的文件名等文件属性输出到csv中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试输出文件属性,例如文件名,创建日期以及整个system32文件夹的MD5哈希值。
通过此解决方案在Powershell中使用这些Commandlet

Im trying to output file properties like filename, date created along with MD5 hash for the entire system32 folder.using these commandlets in powershell from this solution running two powershell commandlets into a single command

 Get-FileHash C:\Windows\System32\drivers\ -Algorithm SHA1 |Select *,@{Label='VersionInfo';Expression={(Get-Item $_.Path).VersionInfo}} |Export-Csv c:\b.csv

我希望每个文件属性的csv格式在单独的列中。
Anyhelp wud意味着很多!

I want the format in csv in separate columns for each file property.Anyhelp wud mean a lot!

推荐答案

Get-ChildItem C:\Windows\System32\ | Select-Object Name,CreationTime,@{n='MD5';ex={(Get-FileHash $_.fullname).hash}}

如果还要从子目录中获取文件,请使用 -Recurse 参数:

Use -Recurse parameter if you want to get files from sub directories also:

Get-ChildItem C:\Windows\System32\ -Recurse

如果只想获取文件而不是文件夹,请使用 -File 参数:

Use -File parameter if you want to get only files and not folders:

Get-ChildItem C:\Windows\System32\ -Recurse -File

键入以下命令以获取所有可用属性的列表:

Type the following command to get the list of all available properties:

Get-ChildItem | Get-Member

这篇关于将Powershell中的文件名等文件属性输出到csv中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 13:32
查看更多