Reputation: 277
(EDIT: Just found this: https://github.com/PowerShell/PowerShell/issues/20711)
Here's sample log files being used for input:
Checksumlog1:
HEADERINFO
18545E9BB9BC5669B755FA080327654EBDF6D49E6356FE24EEA774B282925BFB \steamapps\appmanifest_1036890.acf 798 20230919_003055
E7D827A9819C00492D48CA6C5086ACB7B9DB23E21C43CD4A76668878ACF21484 \steamapps\appmanifest_1046030.acf 793 20231124_005300
442175C0E8F340DDA951C94CFEE503A227645234C23820CC921E7AB71AEFCF69 \steamapps\appmanifest_1086410.acf 762 20230413_034326
BC93D12F756BDE996671C728293756F1DE8CD4B27C0DA623885592E1EC462009 \steamapps\appmanifest_1091500.acf 925 20231026_112000
9D0A9B7E826128B02C3504C554D2965DF65E0A91056200D7B275875FFEEDEC49 \steamapps\appmanifest_1151640.acf 901 20230512_235832
Checksumlog2:
HEADERINFO
BC93D12F756BDE996671C728293756F1DE8CD4B27C0DA623885592E1EC46200? \steamapps\{appmanifest_1091500}.acf 925 20231026_112000
9D0A9B7E826128B02C3504C554D2965DF65E0A91056200D7B275875FFEEDEC49 \steamapps\appmanifest_1151640.acf 901 20230512_235832
7B62186E313EFEA918599B049B1C1B22E3875C5CE542BDC50DB4BCF118397D66 \steamapps\appmanifest_1153640.acf 824 20230713_005243
B47CA151C7542B3C2937626A3513509284E2DF2C34C392A37BF2CC88502D07A0 \steamapps\appmanifest_1164940.acf 828 20231108_120209
5CBE6C2DE7CC4954E7D423C9B75D0B59986673FC36A3CD398E3FB89ED0F8B28F \steamapps\appmanifest_1174180.acf 1420 20231121_211150
Here's the code:
$checksumlog1Content = Get-Content "checksumlog1.log" -Encoding UTF8 | Select -skip 1
$checksumlog2Content = Get-Content "checksumlog2.log" -Encoding UTF8 | Select -skip 1
$checksumlog1Objects = $checksumlog1Content | ForEach-Object {
$checksum = ($_ -Split ' ',2)[0]
$file = ((($_ -Split ' ',2)[1]) -split ' ' | select -skiplast 2) -join ' '
$sizedate = ($_ -Split ' ' | select -last 2) -join ' '
[PSCustomObject]@{
'Hash' = $checksum
'File' = $file
'SizeDate' = $sizedate
}
}
$checksumlog2Objects = $checksumlog2Content | ForEach-Object {
$checksum = ($_ -Split ' ',2)[0]
$file = ((($_ -Split ' ',2)[1]) -split ' ' | select -skiplast 2) -join ' '
$sizedate = ($_ -Split ' ' | select -last 2) -join ' '
[PSCustomObject]@{
'Hash' = $checksum
'File' = $file
'SizeDate' = $sizedate
}
}
$CompareLog1Log2Obj = Compare-Object $checksumlog1Objects $checksumlog2Objects -Property Hash,File,SizeDate -PassThru -IncludeEqual| ForEach-Object { $_ }
$nonMatchLog1Obj = $CompareLog1Log2Obj | Where-Object SideIndicator -eq '<='
$nonMatchLog2Obj = $CompareLog1Log2Obj | Where-Object SideIndicator -eq '=>'
$groupDiff = Compare-Object $nonMatchLog1Obj $nonMatchLog2Obj -IncludeEqual -Property Hash,File -PassThru | Group-Object File | Where-Object Count -ge 2
ForEach ($item in $groupdiff.Group) {
"$($item.Hash) $($item.File) $($item.SizeDate) $($item.SideIndicator)"
}
If the filename contains a curly bracket "{" or "}" (like I added in "checksumlog2.log" it throws an error:
Input string was not in a correct format. Failure to parse near offset 12. Expected an ASCII digit.
Is there a (hopefully simple) way to get this to accept those curly brackets? Thanks.
Upvotes: 0
Views: 221
Reputation: 277
This appears to be an issue with current release PowerShell version 7.4.0. It is fixed with latest Release Candidate 7.4.0.101: https://github.com/PowerShell/PowerShell/issues/20711
Upvotes: 0