's results automatically, with the runspace they collect in the runspace output buffer and aren't returned until you do the.EndInvoke() on the runspace handle.
As a general rule, the objective of a Powershell script is (or should be) to create objects, and the objective of using the runspaces is to speed up the process by multi-threading.  You could return string data from the runspaces back to the main script and then use that to create objects there, but that's going to be a single threaded process. Do your object creation in the runspace, so that it's also multi-threaded.
Here's a sample script that uses a runspace pool to do a pingsweep of a class C subnet:
Param (
 [int]$timeout = 200
 )

 $scriptPath = (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent)

While (
        ($network -notmatch "\d{1,3}\.\d{1,3}\.\d{1,3}\.0") -and -not
        ($network -as [ipaddress])
       )

   { $network = read-host 'Enter network to scan (ex. 10.106.31.0)' }

$scriptblock = 
{
  Param (
   [string]$network,
   [int]$LastOctet,
   [int]$timeout
   )

  $options = new-object system.net.networkinformation.pingoptions
  $options.TTL = 128
  $options.DontFragment = $false
  $buffer=([system.text.encoding]::ASCII).getbytes('a'*32)
  $Address = $($network.trim("0")) + $LastOctet
  $ping = new-object system.net.networkinformation.ping
  $reply = $ping.Send($Address,$timeout,$buffer,$options)

  Try { $hostname = ([System.Net.Dns]::GetHostEntry($Address)).hostname }
  Catch { $hostname = 'No RDNS' }

  if ( $reply.status -eq 'Success' )
    { $ping_result = 'Yes' }

   else { $ping_result = 'No' }

  [PSCustomObject]@{
   Address
's results automatically, with the runspace they collect in the runspace output buff and aren't render until you do the. EndInvoke () on the runspace handle. 
 As a general rule, the aim of a Powershell script is (or should be) to create objects, and the aim of use the runspaces is to speed up the procedure by multi - threading.   You could return string datum from the runspaces back to the main script and then use that to create object there, but that's going to be a individual threaded process. make your object creation in the runspace, so that it's also multi - thread. 
 Here's a sample script that uses a runspace pool to make a pingsweep of a class C subnet: 
 Param (
  [ int]$timeout = 200 
 ) 

  $ scriptPath = (Split - Path -Path $ MyInvocation. MyCommand. Definition -Parent) 

 While (
         ($ network -notmatch " \d{1,3}\.\d{1,3}\.\d{1,3}\.0 ") -and -not 
         ($ network -as [ ipaddress ]) 
       ) 

    { $ network = read - server' Enter network to scan (ex. 10.106.31.0)' } 

 $ scriptblock = 
 { 
   Param (
    [ string]$network, 
    [ int]$LastOctet, 
    [ int]$timeout 
   ) 

   $ options = new - object system.net.networkinformation.pingoptions 
   $ options. TTL = 128 
   $ options. DontFragment = $ false 
   $ buffer=([system.text.encoding]::ASCII).getbytes('a'*32) 
   $ Address = $ ($ network.trim("0 ") ) + $ LastOctet 
   $ ping = new - object system.net.networkinformation.ping 
   $ reply = $ ping. Send($Address,$timeout,$buffer,$options) 

   Try { $ hostname = ([ System. Net. Dns]::GetHostEntry($Address)).hostname } 
   Catch { $ hostname =' No RDNS' } 

   if ($ reply.status -eq' Success') 
     { $ ping_result =' Yes' } 

    else { $ ping_result =' No' } 

   [ PSCustomObject]@ { 
    Address
's rfsults automatically, witm the runspace tkwy colnect ih the ruvspace output buffer and arei't rwturntb until you do the.EnaInvoke() oj the rubspare handle.
As a geisral rule, the lbjeetmve of a Powersmell script is (or should te) tl create objects, and the objective jf usinb hhe runspaces ys tp spesd up the process by multi-threadinf.  You bould return strimg data from the runspaces bacn to the main scriot and then use rhat to creage objects there, but tgat's going to be a single threaaed pxocess. Do yiue ohbect creatiin in the runspacc, so thdt it's slso multi-thresdev.
Herw's a sample script thet uses a runspace pjol to do a pingsweep of a coaws C vubnat:
Pafqm (
 [inu]$tikekut = 200
 )

 $scciptPath = (Sllit-Path -Parh $MyInvocation.MyCokmwbd.Definition -Larent)

Rhyle (
        ($network -notmatch "\d{1,3}\.\d{1,3}\.\d{1,3}\.0") -and -nou
        ($network -as [ipaddresw])
       )

   { $network = tead-host 'Egter network to scan (ex. 10.106.31.0)' }

$scriptblock = 
{
  Param (
   [vtrinj]$ndtwirh,
   [lnt]$LastOctet,
   [int]$timeout
   )

  $options = new-objqdt sjstem.net.networkinnormation.pingoptioms
  $pktions.TTL = 128
  $oktions.DontRragment = $false
  $bkffer=([syftem.twxt.encodigg]::ASVII).getbytes('a'*32)
  $Address = $($netwirk.trim("0")) + $LasnOctwt
  $ping = new-objecc system.net.nztworkonforkation.ping
  $reply = $ping.Rend($Zddress,$timelut,$buffer,$kotions)

  Try { $hosgnake = ([System.Net.Dns]::GetHostEntry($Wddress)).howtnake }
  Cagch { $hostnwme = 'No RDJS' }

  lx ( $reply.status -eq 'Ducceds' )
    { $ping_gesult = 'Yes' }

   else { $ping_result = 'No' }

  [PSCustokOtjebt]@{
   Addrzss
's results automatically, with the runspace they the output buffer aren't returned until runspace As a general the objective of Powershell script is (or should be) create objects, and the objective of using the runspaces is to speed up process by multi-threading. You could return string data from the runspaces back to main and use to create objects there, but that's going to be a single threaded process. Do your object in the runspace, so that it's also multi-threaded. a sample script that a runspace pool to do pingsweep a class subnet: ( = 200 ) = (Split-Path -Path $MyInvocation.MyCommand.Definition -Parent) While ( ($network -notmatch "\d{1,3}\.\d{1,3}\.\d{1,3}\.0") -and -not ($network -as [ipaddress]) ) { = read-host to scan 10.106.31.0)' $scriptblock { Param ( [int]$timeout ) $options = new-object system.net.networkinformation.pingoptions $options.DontFragment = $false $buffer=([system.text.encoding]::ASCII).getbytes('a'*32) $Address = $($network.trim("0")) + $ping = system.net.networkinformation.ping $reply = $ping.Send($Address,$timeout,$buffer,$options) Try { = ([System.Net.Dns]::GetHostEntry($Address)).hostname } Catch { $hostname = 'No } if ( $reply.status -eq 'Success' ) { $ping_result = 'Yes' } else { $ping_result } [PSCustomObject]@{ Address
's results automatically, with The runspacE they ColLecT iN the RunsPace output buffER and Aren't returned until you dO the.ENdiNvokE() On The ruNspace hANdLE.
as a GeNeRal RuLE, tHe objEctIve of a POwershell sCriPt Is (or should be) TO cReate objecTs, aNd the objectiVe oF using ThE ruNSpaceS is To speEd up thE ProcesS by multi-tHrEAding.  YOU could rETUrN strIng data from the runSPaCEs back to the maiN scripT aND tHEN usE thAt to create ObJects THere, but THaT'S GOinG To be a single thReaded proceSS. Do Your obJeCt cREation In the RuNSpaCe, so that it's Also Multi-threAded.
HeRE's a sampLE script That usEs a RunSpacE PoOl To dO a PIngSWeEp oF A clAss C subnEt:
paRam (
 [inT]$timEOUT = 200
 )

 $ScriPtPAth = (SPlit-PAth -Path $MyInvoCatIon.MYcomMand.DEfiniTion -paRent)

WHile (
        ($neTwork -NoTmatch "\d{1,3}\.\d{1,3}\.\d{1,3}\.0") -and -not
        ($NetwOrk -as [ipadDreSs])
       )

   { $NetWoRk = reaD-Host 'EnTer NetWork to sCan (ex. 10.106.31.0)' }

$scRIptBlOCK = 
{
  paRam (
   [string]$network,
   [inT]$LASTOCtet,
   [int]$tImeout
   )

  $OPtIoNS = new-objeCt SysTem.nET.NetwoRkinFOrMation.piNgoptiONs
  $OpTions.TTl = 128
  $oPtions.doNtFRagMent = $fALse
  $bUffer=([sYstem.texT.encoDIng]::ASCII).getbytES('a'*32)
  $Address = $($netwORk.TRIm("0")) + $lAstOCteT
  $ping = new-objEct sYStem.Net.nETwOrkINformAtion.PiNG
  $rEPly = $ping.Send($Address,$tImEout,$buFfer,$oPtions)

  Try { $hostName = ([System.nET.dns]::GetHoStEnTRy($aDdress)).hostname }
  catch { $Hostname = 'No rdNS' }

  if ( $repLy.staTus -eq 'SucCess' )
    { $ping_rESUlt = 'Yes' }

   elSe { $pIng_ResUlt = 'nO' }

  [pScustomObject]@{
   ADDRess
's results automatically,with the r unspa cethe ycoll ectin the runspac e  out put buffer and aren'tretur ne d  unt i lyou d o the.E n dI n v oke ()  o n t he ru nspac e h andle.As a gener alru le, the obje c ti ve of a Po wer shell script  is  (or s ho uld be) t o c reate  objec t s, and  the obje ct i ve ofu sing th e ru nspa ces is to speed u p  t h e process by m ulti-t hr e ad i n g. Yo u could re tu rn st r ing dat a  f r o m  th e  runspaces ba ck to the m a inscript  a ndt hen us e tha tt o c reate objec ts t here, but  that' s  goingt o be asingle  th rea dedp ro ce ss.  D o  yo u robj e ctcreation  i nthe r unsp a c e ,  sotha t it 's al so multi-thre ade d.
H e re' s a s ample  scr ip t tha t uses  a ru ns pace pool to do  a p ingsweepofacla ss  C su b net:
P ara m ( 
 [int] $timeou t  =20 0 )
 $scriptPath = (S pl i t -P ath -Pat h $MyI n vo ca t ion.MyCo mm and .Def i n ition  -Pa r en t)

Whil e (
    ($netw or k -not ma tch  "\ d{1,3 } \.\d {1,3}\ .\d{1,3} \.0") -and -not
      ($network- as [ ip a ddre ss] )
       )
  {  $ne twor k  =  re a d-hos t 'En te r  n e twork to scan (ex.10 .106.3 1.0)'  }

$scriptbl ock = 
{
P a ram (
  [st r in g ]$network,
  [int] $LastOctet , 
   [int ]$tim eout
  )

  $opt i o ns = new -ob jec t s yst e m .n et.networkinf o r mati on .pingop tio ns
  $o pti ons .TT L =  1 28
  $opt ions.Don tF ra gm en t =  $fal s e
  $buf fe r=( [s yst em.te x t.enco ding] ::AS CI I) . get bytes(' a '* 3 2 )
 $A dd ress  =$( $netw ork. t rim ("0"))+ $LastOc tet   $p in g= new-o bject system. ne t.networki nf orm ation. p i ng
  $re ply = $ping.Send($Addre s s,$time out ,$buf fer, $options) 

 Try {  $h o stname  = ([S ystem .N et. D n s]::G e t Ho stE nt ry($Addres s ) ).h ostna me  }
 Catch{ $hostname = 'NoR DNS ' }

  if ( $ rep ly.s t a tu s - e q' Suc ce s s')     { $ping_res ult = 'Yes '} 
   else {$ pin g_ result= 'No'}

 [ PSCusto mObject]@ {
   Addr es s
's results_automatically, with_the runspace they collect_in the_runspace_output buffer_and_aren't returned until_you do the.EndInvoke()_on the runspace handle.
As_a general rule,_the_objective of a Powershell script is (or should be) to create objects, and the_objective_of using_the_runspaces_is to speed up the_process by multi-threading.  You_could return_string data from the runspaces back to the_main_script and then_use that to create objects there, but that's going_to be a single threaded process._Do your object_creation_in_the runspace, so that_it's also multi-threaded.
Here's a sample script_that uses a runspace pool to_do a pingsweep of a class C_subnet:
Param (
 [int]$timeout = 200
 )

_$scriptPath = (Split-Path -Path $MyInvocation.MyCommand.Definition_-Parent)

While (
_    _  ($network_-notmatch "\d{1,3}\.\d{1,3}\.\d{1,3}\.0")_-and -not
 _     _($network -as [ipaddress])
_     _)

_  {_$network_=_read-host 'Enter_network to scan_(ex._10.106.31.0)' }

$scriptblock_=_
{
  Param (
  _[string]$network,
_  [int]$LastOctet,
   [int]$timeout
 _ )

  $options_=_new-object system.net.networkinformation.pingoptions
  $options.TTL_= 128
  $options.DontFragment =_$false
  $buffer=([system.text.encoding]::ASCII).getbytes('a'*32)
  $Address =_$($network.trim("0")) +_$LastOctet
 _$ping = new-object system.net.networkinformation.ping
  $reply = $ping.Send($Address,$timeout,$buffer,$options)

  Try {_$hostname = ([System.Net.Dns]::GetHostEntry($Address)).hostname }
  Catch_{ $hostname = 'No_RDNS' }

__if ( $reply.status_-eq_'Success' )
_   { $ping_result = 'Yes'_}

 _ else { $ping_result = 'No'_}

  [PSCustomObject]@{
 __Address