title: Issues getting multiple PSCustomObject's to export properly in PowerShell
body: <p>I am try to export out 8 objects in <code>[PSCustomObect]</code> to a csv. It only sorta works.</p>
  
  <p>The data is organized nicely in the viewer.</p>
  
  <p><a href="https://i.stack.imgur.com/Q8PE5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q8PE5.png" alt="enter image description here"></a></p>
  
  <p>But the actual CSV export is a mess. Every RegEx match (PSCustomerObject) is a new line instead of being one line per device (Rather, one line per foreach loop object)</p>
  
  <p><a href="https://i.stack.imgur.com/6iVp1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6iVp1.png" alt="enter image description here"></a></p>
  
  <p>What am I missing here? </p>
  
  <pre><code>$content = Get-Content -Path "U:\Dump\dump.nmap"-RAW
  #$RegX_splitter = '(?m)(?=^Nmap scan report for )'
  $RegX_DeviceIP = '(?sm)Nmap scan report for\s*(?&lt;DeviceIP&gt;.*?)$'
  $RegX_DeviceType = '(?sm)Device type:\s*(?&lt;DeviceType&gt;.*?)$'
  $RegX_OS = '(?sm)Running:\s*(?&lt;OS&gt;.*?)$'
  $RegX_OSdetails = '(?sm)OS details:\s*(?&lt;OSdetails&gt;.*?)$'
  $RegX_Servicesplit='(?sm)(?=^23\/tcp)(?&lt;port&gt;\d+\/\w+)\s+(?&lt;state&gt;\w*?)\s+(?&lt;service&gt;\w*?)\s+(?&lt;description&gt;.*?)$'
  $counter = 0
  
  $data = $content -split 'TRACEROUTE' | ForEach-Object{
  
      $counter = $counter + 1
      write-host "============================================="
      write-host $counter
      write-host "============================================="
  
      if ($_ -match $RegX_DeviceIP){
          write-host 'The Device Name (IP) is:'$Matches.DeviceIP
      }
      if ($_ -match $RegX_Servicesplit){
          write-host 'The port number is:'$Matches.Port
          write-host 'The port is:'$Matches.State
          write-host 'The service running is:'$Matches.Service
          write-host 'The Service description is:'$Matches.Description
      }
      if ($_ -match $RegX_DeviceType){
          write-host 'The Device Type is:'$Matches.DeviceType
      }
      if ($_ -match $RegX_OS){
          write-host 'The OS is:'$Matches.OS
      }
      if ($_ -match $RegX_OSdetails){
          write-host 'The OS details are:'$Matches.OSdetails
      }     
      [PSCustomObject]@{
          DeviceIP = $Matches.DeviceIP
          Port = $Matches.Port
          State = $Matches.State
          Service = $Matches.Service
          Description = $Matches.Description
          DeviceType= $Matches.DeviceType
          OS = $Matches.OS
          OSdetails = $Matches.OSdetails
       }
  
  }
  
  $data | Export-Csv "U:\Dump\testexport.csv" -NoTypeInformation
  $data | Format-Table -AutoSize
  </code></pre>
  
  <p><strong>SAMPLE INPUT</strong></p>
  
  <pre><code>Nmap scan report for 10.0.0.1
  Host is up (0.000060s latency).
  Not shown: 997 closed ports
  PORT     STATE SERVICE    VERSION
  23/tcp   open  telnet     SMC SMC2870W Wireless Ethernet Bridge
  80/tcp   open  tcpwrapped
  | http-auth: 
  | HTTP/1.1 401 Unauthorized\x0D
  |_  Basic realm=GatewayAdmin
  |_http-title: Site doesn't have a title (text/html).
  5060/tcp open  sip        (SIP end point; Status: 200 OK)
  | fingerprint-strings: 
  |   SIPOptions: 
  |     SIP/2.0 200 OK
  |     Content-Type:application/sdp
  |     Supported:replaces,100rel,timer
  |     Allow:INVITE,ACK,OPTIONS,BYE,CANCEL,REGISTER,INFO,PRACK,REFER,NOTIFY
  |     From:&lt;sip:nm@nm&gt;;tag=root
  |     To:&lt;sip:nm2@nm2&gt;;tag=4EFF32463135364101C48D67
  |     Call-ID:50000
  |     CSeq:42 OPTIONS
  |     Server:PBX-IP Media Gateway/2.1
  |     Via:SIP/2.0/TCP nm;branch=foo;received=10.0.232.59
  |_    Content-Length:0
  1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
  SF-Port5060-TCP:V=7.80%I=7%D=8/28%Time=5D669285%P=i686-pc-windows-windows%
  SF:r(SIPOptions,168,"SIP/2\.0\x20200\x20OK\r\nContent-Type:application/sdp
  SF:\r\nSupported:replaces,100rel,timer\r\nAllow:INVITE,ACK,OPTIONS,BYE,CAN
  SF:CEL,REGISTER,INFO,PRACK,REFER,NOTIFY\r\nFrom:&lt;sip:nm@nm&gt;;tag=root\r\nTo
  SF::&lt;sip:nm2@nm2&gt;;tag=4EFF32463135364101C48D67\r\nCall-ID:50000\r\nCSeq:42
  SF:\x20OPTIONS\r\nServer:PBX-IP\x20Media\x20Gateway/2\.1\r\nVia:SIP/2\.0/T
  SF:CP\x20nm;branch=foo;received=10\.0\.232\.59\r\nContent-Length:0\r\n\r\n
  SF:");
  Device type: VoIP phone
  Running: Aastra embedded
  OS details: Aastra Dialog 4425 IP phone
  Network Distance: 4 hops
  Service Info: Device: bridge
  
  TRACEROUTE (using port 22/tcp)
  HOP RTT     ADDRESS
  1   0.00 ms 10.X.X.254
  2   0.00 ms 10.X.X.73
  3   0.00 ms 10.X.X.1
  4   0.00 ms 10.X.X.13
  </code></pre>