How to receive result of multiple jobs ?


i unable  receive result of jobs.

function main

{  

    $numbers=($args[0],$args[1])    

    $myjob = $args[0]+"and"+$args[1]

    $job=start-job -name $myjob -scriptblock {

    param ([int[]] $list)    

    $f=$list[0]

    $s=$list[1]

       function sum($a,$b)

        {   

            for($i=0;$i -lt 1000000;$i++)

            {

                if($i -eq 999999)

                {     

                    $c=$a+$b

                }

            }

            return $c

        }   

        sum $f $s

    }-argumentlist (,$numbers)

        receive-job $myjob | out-file $pshome\$filename #output file doesn't show anything

}

$numbers=get-content "d:\powersh\input.txt"

$filename="output.txt"

foreach($firstnumber in $numbers)

{

    foreach($secondnumber in $numbers)

    {

        if($firstnumber -eq $secondnumber)

        {

            continue

        }

        else

        {

            main $firstnumber $secondnumber

        }

    }

}

 

this how ps console looks when quick get-job:

 

ps c:\windows\system32\windowspowershell\v1.0> get-job

 

id              name            state      hasmoredata     location             comm

and

--              ----            -----      -----------     --------             ----

---

367             3and2           running    true            localhost            ... 

 

365             3and1           running    true            localhost            ... 

 

363             2and3           running    true            localhost            ... 

 

361             2and1           running    true            localhost            ... 

 

359             1and3           running    true            localhost            ... 

 

357             1and2           running    true            localhost            ... 

 

but output file blank.

   receive-job $myjob | out-file $pshome\$filename -append  

or

   receive-job $myjob >> $pshome\$filename  



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

some help on Event 540

WMI Repository 4GB limit - Win 2003 Ent Question

Event ID 1302 (error 1307) DFS replication service encountered an error while writing to the debug log file