title: How to Invoke below script block using Invoke-parallel
body: <p>This Invoke-Parallel is taken from <a href="https://github.com/RamblingCookieMonster/PowerShell/blob/master/Invoke-Parallel.ps1" rel="nofollow noreferrer">here</a></p>
  <p>Below is my script block</p>
  <pre><code>$scriptblock ={
  get-service -ComputerName $parameter.computername | where {$_.name -eq $parameter.serviceName }
  }
  </code></pre>
  <p>below is a custom object</p>
  <pre><code>$pscustomobject = @()
  
  $pscustomobject += [pscustomobject]@{
  Computername ='server1'
  Servicename =&quot;service1&quot;
  }
  
  $pscustomobject += [pscustomobject]@{
  Computername ='server2'
  Servicename =&quot;service2&quot;
  }
  </code></pre>
  <p>I tried using Invoke-Parallel using below method ,but this doesnt work</p>
  <pre><code>Invoke-Parallel -ScriptBlock $scriptblock -Parameter $pscustomobject
  
  &quot;server1&quot;,&quot;server2&quot; | Invoke-Parallel -ScriptBlock $scriptblock -Parameter $pscustomobject
  </code></pre>
  <p>Few services exist in few servers and on few others,they dont,so created a custom object which tightly maps services to servers.</p>
  <p>Any ideas would be greatly helpfull</p>