Essaie ceci :
1 2 3 4 5 6 7 8
| $index = 0
$content = Get-Content -LiteralPath "data.txt" -Encoding UTF8 | ForEach-Object {
[PSCustomObject]@{line = $index++;txt = $_}
}
$grp = $content| Group-Object -Property txt
$grp | Where-Object {$_.Count -gt 1} | ForEach-Object {Write-Host "Erreur lignes $($_.Group.line -join ", ") : $($_.Name)"} |
Équivalent condensé :
$index = 0;Get-Content -LiteralPath "data.txt" -Encoding UTF8 | ForEach-Object {[PSCustomObject]@{line = $index++;txt = $_}} | Group-Object -Property txt | Where-Object {$_.Count -gt 1} | ForEach-Object {Write-Host "Erreur lignes $($_.Group.line -join ", ") : $($_.Name)"}
Partager