[英]Powershell - send output to excel file
I have a script that creates a table from scanning 10's of thousands of files.我有一个脚本可以通过扫描数千个文件来创建一个表。 The output of the table ends up on the screen.
表格的 output 最终出现在屏幕上。 I need to take that screen output and convert it to something that can be ingested into excel. Most likely a CSV file.
我需要获取该屏幕 output 并将其转换为可以摄取到 excel 中的内容。很可能是一个 CSV 文件。
This is the code that takes a previously created table and extracts the information I need, then prints it on the screen.这是采用先前创建的表格并提取我需要的信息,然后将其打印在屏幕上的代码。
Would someone be able to help me convert this information to a CSV file where the HASH and FULL Name would be the headings for the two columns and then the Hash data in column 1 under the Hash heading and the full name data in column 2 under the full name heading?有人可以帮助我将此信息转换为 CSV 文件,其中 HASH 和全名将是两列的标题,然后是 Hash 标题下第 1 列中的 Hash 数据和第 2 列中的全名数据全名标题?
# output duplicates
& { foreach($key in $result.Keys)
{
foreach($file in $result[$key])
{
$file |
Add-Member -MemberType NoteProperty -Name Hash -Value $key -PassThru |
Select-Object Hash, Length, FullName
}
}
} | Format-Table -GroupBy Hash -Property FullName
Here is what the output looks like on the screen这是 output 在屏幕上的样子
Hash: 7827DDE006149320136B029A866282F40C109EE3:12231 Hash: 7827DDE006149320136B029A866282F40C109EE3:12231
C:\P$$$RA1.pl1 C:\src\P$$$RA1.pl1 C:\P$$$RA1.pl1 C:\src\P$$$RA1.pl1
Hash: D230CF0EA5C31AF21C82338AFE1FE5E7FB9E1A2E:709 Hash: D230CF0EA5C31AF21C82338AFE1FE5E7FB9E1A2E:709
C:$ISPMLIB.proc C:\src$ISPMLIB C:$ISPMLIB.proc C:\src$ISPMLIB
C:\source-code$ISPMLIB.proc C:\源代码$ISPMLIB.proc
Hash: 138F79F72D56B5ECB8C3C3B7F584962C6A3750E2:11421 Hash: 138F79F72D56B5ECB8C3C3B7F584962C6A3750E2:11421
C:\Z$SDENT.pl1 C:\src\Z$SDENT.pl1 C:\Z$SDENT.pl1 C:\src\Z$SDENT.pl1
See comments to question - Export to CSV worked great查看问题评论 - 导出到 CSV 效果很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.