Start-job to call script from main

Posted by Naveen on Stack Overflow See other posts from Stack Overflow or by Naveen
Published on 2012-11-12T10:57:29Z Indexed on 2012/11/12 10:59 UTC
Read the original article Hit count: 301

Filed under:
|

I have three script , from main - 1-script , I am calling other two scripts. so that I can execute both scripts parallely because it's taking too much time in sequential order. Only variables are different in the script.

How can I merge script 2 & 3 in a single script so that I can call from the main script and it will run as parallel.

1 CompareCtrlM... Completed False localhost ######################...

3 CompareCtrlM... Completed True localhost ######################...

Main -1 Script Start-Job -Name "LoopComparectrlMasterModel" -filepath D:\tmp\naveen\Script\CompareCtrlMasterCtrlModel.ps1 Start-Job -Name "LoopCompareProdMasterModel" -filepath D:\idv\CA\rcm_data\tmp\work\CompareCtrlMasterProdModel.ps1

Wait-Job -Name "LoopComparectrlMasterModel"
Receive-Job "LoopComparectrlMasterModel"
Wait-Job -Name "LoopCompareProdMasterModel"
Receive-Job "LoopCompareProdMasterModel"

=============================================== Script 2-

for ($i = 1 ; $i -lt 3; $i++){
     $jobName = 'CompareCtrlMasterProdModelESS$i'
    echolog $THISSCRIPT $RCM_UPDATE_LOG_FILE $LLINFO ("Starting Ctrl Master-Prod Model comparison #" + $i + ", create SBT")
    $rc = CreateSbtFile $sbtCompareCtrlMasterProdModel[$i-1] $cfgProdModel $cfgCtrlMaster "" "" $SBT_MODE_COMPARE_CFGS_FULL $workDir
    Start-Job -Name "$jobName" -filepath $ExecuteSbtWithRcmClientTool -ArgumentList $sbtCompareCtrlMasterProdModel[$i-1],"",$true,$false | Out-Null

Wait-Job -Name "$jobName"
$results = Receive-Job -Name $jobName


}

========================================================================== Script 3-

for ($i = 1 ; $i -lt 3; $i++){
     $jobName = 'CompareCtrlMasterCtrlModelESS$i'
    echolog $THISSCRIPT $RCM_UPDATE_LOG_FILE $LLINFO ("Starting Ctrl Master-Ctrl Model comparison #" + $i + ", create SBT")
    $rc = CreateSbtFile $sbtCompareCtrlMasterCtrlModel[$i-1] $cfgCtrlModel $cfgCtrlMaster "" "" $SBT_MODE_COMPARE_CFGS_FULL $workDir
    Start-Job -Name "$jobName" -filepath $ExecuteSbtWithRcmClientTool -ArgumentList $sbtCompareCtrlMasterCtrlModel[$i-1],"",$true,$false | Out-Null

Wait-Job -Name "$jobName"
$results = Receive-Job -Name $jobName


}

write-output $results

Thanks a lot for help

Regards Naven

© Stack Overflow or respective owner

Related posts about powershell

Related posts about powershell-v2.0