PowerShell代码制动器作为脚本运行时,但不在控制台中

时间:2018-05-02 16:10:49

标签: powershell console ps1

我不知道出了什么问题,当我从ps1脚本运行此代码时,它会中断。

但是,当我将其直接粘贴到PowerShell控制台时似乎有效,我尝试更改行缩进但无效。

foreach($A in 1..20){

    $i = 1;
        $link =((Invoke-WebRequest –Uri "http://example.com/").Links | Where innerHTML -like "*.mkv" | Select -First $i).href 
        C:\path\aria2c.exe http://example.com/$link --dir=C:\path\ --max-connection-per-server=16 -k 1M -s 10 -x 10
    do { $i; $i +=1 } until ($i -gt 20)

  Write-Host $A
}

错误消息

At C:\path\script.ps1:4 char:102
+ ... /Ad/").Links | Where innerHTML -like "*.mkv" | Select -First $i).href
+                                                ~~~~~~~~~~~~~~~~~~~~~~~~~~
The string is missing the terminator: ".
At C:\path\script.ps1:10 char:1
+
Missing closing ')' in expression.
At C:\path\script.ps1:1 char:21
+ foreach($A in 1..20){
+                     ~
Missing closing '}' in statement block or type definition.
+ CategoryInfo          : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

0 个答案:

没有答案
相关问题