在 Powershell 中获取具有其他属性的文件哈希值
Get files hashes with other attributes in Powershell
我需要在 Powershell 中获取 Date Created
、Date Modified
以及文件哈希,所以我的想法是使用此命令
gci -Recurse | select Name, CreationTime, LastWriteTime
并在末尾或 get-ChildItem
之后和 Select
之前追加 Get-FileHash
。
这个问题,正如我分析的那样,Get-FileHash
需要一个路径,所以如果放在最后它就不起作用,它可以工作但是如果 Select
放在前面就失败了。
知道如何解决这个问题,这是比较日期的最佳方式还是应该将它们转换为其他格式。
将 Select-Object
与 a calculated property 结合使用 - 您将可以通过从 Get-ChildItem
:
向下传输的对象访问路径
Get-ChildItem -Recurse -File |Select Name,CreationTime,LastWriteTime,@{Name='SHA256Hash';Expression={(Get-FileHash -LiteralPath $_.FullName).Hash}}
我需要在 Powershell 中获取 Date Created
、Date Modified
以及文件哈希,所以我的想法是使用此命令
gci -Recurse | select Name, CreationTime, LastWriteTime
并在末尾或 get-ChildItem
之后和 Select
之前追加 Get-FileHash
。
这个问题,正如我分析的那样,Get-FileHash
需要一个路径,所以如果放在最后它就不起作用,它可以工作但是如果 Select
放在前面就失败了。
知道如何解决这个问题,这是比较日期的最佳方式还是应该将它们转换为其他格式。
将 Select-Object
与 a calculated property 结合使用 - 您将可以通过从 Get-ChildItem
:
Get-ChildItem -Recurse -File |Select Name,CreationTime,LastWriteTime,@{Name='SHA256Hash';Expression={(Get-FileHash -LiteralPath $_.FullName).Hash}}