I'm attempting to gather stats on the local ports of a server.
I'm writing the output to a HTML file.
The problem I'm having is that when my String contains, multiple lines wrapped, my script fails.
I'm splitting the line into an array, so that I can format this under certain headers within a HTML page ( This works fine for a single match)
String = TCP Server1:4445 Server2:0 Established
If my String, matches more than one line, then the string is multiple by X.. I need to break down the string, even more.. Some how I need to split the string after the word 'Established' and repopulate the array with these new values.. So some type of ForEach statement me thinks.
[string]$Network_Stats = netstat -a | Select-String -pattern ':4445'
$Fields = $Network_Stats.split('') | Where {$_.Length -gt 0}
$Local_Address = $Fields[1]
$Foreign_Address = $Fields[2]
$Status = $Fields[3]
Any ideas,
Cheers.
Shaun.