Remove blank (lines) from an array


i've tried everyting down't seem work:


#combine both result arrays
$result

$lines = (($result -replace '((udp|tcp) \d{3})', "`$1`n") -split "`n")

foreach($line in $lines){if ([string]::isnullorempty($line)) {$lines =-$line}}

any ideas?  array $lines, has been split lines origina $results array.


alter de ruine

no quite sure why wasn't working.  anyway worked out blank lines 1 char in length, knows char is? :-)

$result

$linearray =@()

$lines = (($result -replace '((udp|tcp) \d{3})', "`$1`n") -split "`n")

$lines = $lines | select -last 10
foreach ($line in $lines){if ($line.length -gt 1){ $linearray += $line }}
$linearray


alter de ruine



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

2008 Windows Deployment Server Properties Error

Can no longer user MS Update - Files required to use Microsoft Update are no longer registered

How do a find data in one file, search for it in another file and if not found, write a custom message to another file