Powershell, Start-Job is not Working. Without Start-job script is Ok
<p>I have written <a href="/questions/tagged/powershell" class="post-tag" title="show questions tagged &#39;powershell&#39;" rel="tag">powershell</a> script to split one file (Containing hostnames) into ten files, perform ping (i.e. powershell test-connection command) to hostnames in each file. To speed up the process, i used start-job command to process each file hostnames. If I remove the start-job command the scripts works just fine, as desired. But when i use the start-job command, the array used inside the "scriptblock" does not return the desired output. Instead, it remains empty. Following is the partial script (for only one file processing). Please guide, what Am I missing here?</p>

<pre><code>Start-Job -Name "Ping-Part-1" -ScriptBlock {
    foreach ($Comp1 in $file_part1_content) {
        If (test-Connection -ComputerName $Comp1 -Count 1 -Quiet) {
                $project1 = Create-New-Object
                $project1.AliveStatus = "Alive"
                $project1.Hostname = $Comp1
                $resultsarray_file1 += $project1
            }
            Else {
                $project1 = Create-New-Object
                $project1.AliveStatus = "Not Alive"
                $project1.Hostname = $Comp1
                $resultsarray_file1 += $project1
            }
        }
    }
</code></pre>