function - Invoke-Command powershell trouble -


friend's i've got trouble function, run on remote server, i've got following output :

invoke-command : positional parameter cannot found accepts argument '& c:\testnunit\dll\'. @ d:\test\multithread.ps1:65 char:16 + invoke-command <<<< -computername $serv -scriptblock $command ([scriptblock]::create("& $oneproject")) -credential $cred + categoryinfo : invalidargument: (:) [invoke-command], parameterbindingexception + fullyqualifiederrorid : positionalparameternotfound,microsoft.powershell.commands.invokecommandcommand

  function nunit  {   ##parse connection parameters $connection = @{"server" = "..."; "username" = "..."; "password" = "...."}  $serv = $connection.get_item("server") $user = $connection.get_item("username") $pass = $connection.get_item("password")  $securepassword = convertto-securestring -asplaintext $pass -force  #create connection credentials object invoke-command $cred   = new-object -typename system.management.automation.pscredential -argumentlist $user, $securepassword  $nunitexe = "c:\testnunit\bin\nunit-console.exe"    $oneproject = "c:\testnunit\dll\foundation.tests.dll" $testprojects = "c:\testnunit\dll\" foreach( $oneproject in ( $testprojects)) {  $workingdir = "c:\testnunit"  $nunitoutput = "c:\testnunit" + $oneproject + ".xml"   $command = {&"$nunitexe" "$workingdir\$oneproject" \noshadow/framework:"net-3.5" /xml:$nunitoutput}   }     invoke-command -computername $serv -scriptblock  $command  ([scriptblock]::create("& $oneproject")) -credential $cred             } 

after -scriptblock parameter specifying 2 scriptblocks - 1 in $command , 1 via create. there should 1 value provided parameter.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -