我有代碼,它使用這個工具https://learn.microsoft.com/en-us/sysinternals/downloads/strings:
$listOfFiles=(Get-ChildItem -Path 'C:\Program Files\test' -Include "*.dll","*.exe" -recurse | ForEach-Object {$_.FullName})
Foreach($file in $listOfFiles)
{
strings.exe -n 10 $file >> test.txt
}
如何將“strings.exe -n 10 $file”命令的結果放入陣列?
因為稍后我想將它們顯示在我創建的 csv 表中。
uj5u.com熱心網友回復:
用于Select-Object為每個字串輸出創建 1 個新物件strings.exe,然后將整個回圈的所有輸出分配給單個變數:
$listOfFiles = Get-ChildItem -Path 'C:\Program Files\test' -Include "*.dll","*.exe" -Recurse |ForEach-Object FullName
$strings = foreach($file in $listOfFiles)
{
strings.exe -n 10 $file |Select-Object @{Name='String';Expression={$_}},@{Name='FilePath';Expression={$file}}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/534702.html
標籤:电源外壳
上一篇:PowershellGet-ChildItem排除默認Windows檔案夾
下一篇:在PowerShell中決議輸出
