Import-CSV Where-Object as a Array

时间:2012-06-18 20:50:08

标签: powershell

我有以下代码工作 - 基于stackoverflow的强大帮助 - 解析CSV文件。我想替换$ _。文件 - 与包含文件列表的第二个CSV文件中的数据匹配。

Import-csv "D:\NTFSInfo_C_.csv" -header("File","ParentName","Extension","Attributes","SizeInBytes","CreationDate","LastModificationDate","LastAccessDate","LastAttrChangeDate","Status","USN","FRN","ParentFRN","FileNameCreationDate","FileNameLastModificationDate","FileNameLastAccessDate","FileNameLastAttrModificationDate")|
  Where-Object{($_.File -match "null.sys") -or ($_.File -match "explorer.exe")} |
  Select-Object File, CreationDate, FileNameCreationDate, ParentName |
  Export-CSV -Path c:\NTFS_KNOW_IOC.csv -NoTypeInformation

问题。如何将TXT或CSV中的文件名列表读入数组,然后在Where-Object中使用该数组,如上所示?

谢谢!

1 个答案:

答案 0 :(得分:2)

$files = Get-Content files.txt
...

Where-Object{($files -match "null.sys") -or ($files -match "explorer.exe")} ...