'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. I need to take that screen output and convert it to something that can be ingested into excel. Most likely a CSV file.
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?
# 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
Hash: 7827DDE006149320136B029A866282F40C109EE3:12231
FullName
C:\P$$$RA1.pl1 C:\src\P$$$RA1.pl1
Hash: D230CF0EA5C31AF21C82338AFE1FE5E7FB9E1A2E:709
FullName
C:$ISPMLIB.proc
C:\src$ISPMLIB
C:\source-code$ISPMLIB.proc
Hash: 138F79F72D56B5ECB8C3C3B7F584962C6A3750E2:11421
FullName
C:\Z$SDENT.pl1 C:\src\Z$SDENT.pl1
Solution 1:[1]
See comments to question - Export to CSV worked great
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user3166462 |
