Powershell create count of duplicate records in a text file

  Kiến thức lập trình

I want to know if a text file has any duplicate records in it. I want to assign a count of these duplications so I can see if it is greater than 0 but I cannot seem to find a good sample.

I tried to load the file into an array then do the following

$A = $arrayFromFile | Group | Where{$_.Count -gt 1} | Select-Object Count 

but it does not come back. Here is a sample record in the file:

4|2024|999000|DETROIT|030|PIPE|WATER-WET UTIL|12-HARDWARE|PIPE|NULL|AX|00.0000000000000000|0.0000000000000000|AMT|DETROIT|PIPE|WATER-WET|12-HARDW|PIPE

New contributor

user24838917 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

LEAVE A COMMENT