powershell 缺少终止符:" [英] powershell is missing the terminator: "

查看:147
本文介绍了powershell 缺少终止符:"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下脚本代码

    #[string]$password = $( Read-Host "Input password, please" )
    param (
        [string]$ReleaseFile = $(throw "-ReleaseFile is required"),
        [string]$Destination = $(throw "-Destination is required")
    )

    function unzipRelease($src, $dst)
    {
        $shell = new-object -com shell.application
        $zip = $shell.NameSpace($src)
        foreach($item in $zip.items())
        {
            $shell.Namespace($dst).copyhere($item)
        }
    }

    #  .\deployrelease.ps1 -ReleaseFile ".\deploy.zip" -Destination "."

    unzipRelease –Src '$ReleaseFile' -Dst '$Destination'

我使用以下命令运行脚本:.\deployrelease.ps1 -ReleaseFile ".\deploy.zip" -Destination "."

I run the script with: .\deployrelease.ps1 -ReleaseFile ".\deploy.zip" -Destination "."

但我一直收到这个:

    PS C:\Users\Administrator\Documents\Tools> .\deployrelease.ps1 -ReleaseFile ".\deploy.zip" -Destination
    The string starting:
    At C:\Users\Administrator\Documents\Tools\deployrelease.ps1:19 char:16
    + unzipRelease â? <<<< "Src '$ReleaseFile' -Dst '$Destination'
    is missing the terminator: ".
    At C:\Users\Administrator\Documents\Tools\deployrelease.ps1:19 char:55
    + unzipRelease â?"Src '$ReleaseFile' -Dst '$Destination' <<<<
        + CategoryInfo          : ParserError: (Src `'$ReleaseF...'$Destination`':String) [], ParseException
        + FullyQualifiedErrorId : TerminatorExpectedAtEndOfString

我找不到修复程序,因为我没有发现任何问题.

I couldn't find the fix as I do not see any problem.

有什么帮助吗?

推荐答案

仔细看

unzipRelease –Src '$ReleaseFile' -Dst '$Destination'

第一个不是普通的破折号而是一个破折号(HTML 中的 &ndash;).将其替换为 Dst 之前的破折号.

This first one is not a normal dash but an en-dash (&ndash; in HTML). Replace that with the dash found before Dst.

这篇关于powershell 缺少终止符:&quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆