how to pass a powershell script file to a job created using "start-job" cmdlet
i have script file takes 2 machine names, port number , few other parameters. script runs ntttcp tool between 2 machines. want multiple combinations of machines run in parallel . created a job within loop passing script file,machine pair as parameters can have more 1 machine pair running in parallel.
my code snippet looks this:
foreach($exclusivemachinepairkey in $htbl_exclusivemachinepairs.keys)
{
$jobname = $exclusivemachinepairkey+"and"+$htbl_exclusivemachinepairs[$exclusivemachinepairkey]
$alljobnames=$alljobnames+$jobname
$jobobj=start-job -filepath d:\powersh\functions\ntttcpstarterscript.ps1 -argumentlist $exclusivemachinepairkey $htbl_exclusivemachinepairs[$exclusivemachinepairkey] $inputport $inputthreadcount $filename -name $jobname
}
when running in debug mode, on passing "start-job" line, see error message:
[dbg]>>> stopped at: if ($_.fullyqualifiederrorid -ne "nativecommanderrormessage" -and $errorview -ne "categoryview") {
start-job : cannot bind parameter 'initializationscript'. cannot convert "fds-320-k27
-8" value of type "system.string" type "system.management.automation.scriptblock".
@ d:\powersh\functions\ntttcpjobscriptstarter.ps1:60 char:26
+ $jobobj=start-job <<<< -filepath d:\powersh\functions\ntttcpstarterscript.ps1
-argumentlist $exclusivemachinepairkey $htbl_exclusivemachinepairs[$exclusivemachinepairk
ey] $inputport $inputthreadcount $filename -name $jobname
+ categoryinfo : invalidargument: (:) [start-job], parameterbindingexceptio
n
+ fullyqualifiederrorid : cannotconvertargumentnomessage,microsoft.powershell.comman
ds.startjobcommand
what doing wrong? please.
$exclusivemachinepairkey,$htbl_exclusivemachinepairs[$exclusivemachinepairkey],$inputport,$inputthreadcount,$filename
Windows Server > Windows PowerShell
Comments
Post a Comment