Powershell create a comma delimited list from array of IP's that occur $N number of times Powershell create a comma delimited list from array of IP's that occur $N number of times windows windows

Powershell create a comma delimited list from array of IP's that occur $N number of times


Here you go, a nice little one-liner for you:

($net_final|group|?{$_.count -ge 5}|Select -ExpandProperty Name) -join ","

That will output:

64.339.161.5,19.19.19.19,63.339.161.7


I had trouble with the solution given by TheMadTechnician, but found the following works great:

$my_array -join ","


Even faster / simpler to read:

$test = (1,3,7,7,3,2,1)$($test | sort -Unique) -join "," 

1,2,3,7

You can pipe any array into sort with the -unique flag to dedupe; the wrapped variable can then be joined with your preferred delimiter.