1

我正在尝试使用这个:

$Properties = @((0,100),(20,200))
$URLS = @(("www.google.com","www.yahoo.com"),("www.bing.com","www.msn.com"))

for ($a=0; $a -le 0; $a++)
{
for ($b=0; $b -le 1; $b++)
    {
        Start-Job -name ("Job"+$a+$b) -FilePath "C:\Users\Robert\Desktop\Voodoo\Voodoo-v2\Jobs\NewJob1-1.ps1" -ArgumentList $a,$b,$Properties,$URLS
        Start-Sleep -Seconds 1
    }
}

要运行这个:

param $c $d $Prop $U

function OpenBrowserWindow([int]$top,[int]$left)
    {
        $date = get-date
        $Global:ie = new-object -comobject "InternetExplorer.Application"  
        $ie.visible = $true  
        $ie.Top = $top
        $ie.Left = $left
        #$ie.FullScreen = $true
    }

function URL($URL1,$URL2)
    {     
        $ie.navigate($URL1) 
        start-sleep -s 5
        $ie.navigate($URL2)
        start-sleep -s 5
    }

OpenBrowserWindow $Prop[$c][$d] $Prop[$c][1];

do
{
    URL $U[$c][$d] $U[$c][1];
}
until ($date.year -ieq 2020)

但我不断得到:

Start-Job : Missing ')' in function parameter list.
At C:\Users\Robert\Desktop\Voodoo\Homer\Tester22.ps1:9 char:13
+             Start-Job <<<<  -name ("Job"+$a+$b) -FilePath "C:\Users\Robert\Desktop\Voodoo\Voodoo-v2\Jobs\NewJob1-1.ps1" -ArgumentList $a,$b,$Properties,$URLS
+ CategoryInfo          : ParserError: (CloseParenToken:TokenId) [Start->Job], ParseException
+ FullyQualifiedErrorId : MissingEndParenthesisInFunctionParameterList,Microsoft.PowerShell.Commands.StartJobCommand

我一遍又一遍地检查了这个东西,但似乎找不到我错过')'的地方

如果有人可以帮助我,我将不胜感激。

4

1 回答 1

0

错误在ps1. 参数必须用括号括起来。

param( $c $d $Prop $U)

function OpenBrowserWindow([int]$top,[int]$left)
    {
        $date = get-date
        $Global:ie = new-object -comobject "InternetExplorer.Application"  
        $ie.visible = $true  
        $ie.Top = $top
        $ie.Left = $left
        #$ie.FullScreen = $true
    }

function URL($URL1,$URL2)
    {     
        $ie.navigate($URL1) 
        start-sleep -s 5
        $ie.navigate($URL2)
        start-sleep -s 5
    }

OpenBrowserWindow $Prop[$c][$d] $Prop[$c][1];

do
{
    URL $U[$c][$d] $U[$c][1];
}
until ($date.year -ieq 2020)
于 2017-01-24T00:23:52.993 回答