I have a text file with a list of IP addresses, and i need to count the number of times the same IP appears in the file.
I've found lots of ways of removing duplicate entries, and how to count the number of lines, but nothing on how to counting duplicate entries.
I haven't got much of a script yet, not anything worth posting, but if someone can point me in the right direction, that will be a start.
If $file
contains
10.1.1.2
10.1.1.2
10.1.1.2
10.1.1.10
10.1.1.10
10.1.1.20
then
Get-Content $file | Group-Object -noelement
Count Name
----- ----
3 10.1.1.2
2 10.1.1.10
1 10.1.1.20
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With