Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用文字字符<&燃气轮机;在Powershell中_Powershell - Fatal编程技术网

使用文字字符<&燃气轮机;在Powershell中

使用文字字符<&燃气轮机;在Powershell中,powershell,Powershell,我有一个命令,下面是我一直在尝试在远程服务器上使用invoke命令运行的命令。我不断收到错误“其中一个解析器正在删除您的引号并尝试解释文件重定向的命令字符。您不需要调用cmd.exe来调用可执行文件,您可以从powershell本机执行(使用调用操作符&): Invoke命令-ComputerName$SourceSrv-ScriptBlock{ &“$using:SourcePath\Bin\svc.exe”“-service='install,svc1,$using:SvcUser,,,M”

我有一个命令,下面是我一直在尝试在远程服务器上使用invoke命令运行的命令。我不断收到错误“其中一个解析器正在删除您的引号并尝试解释文件重定向的
命令字符。您不需要调用
cmd.exe
来调用可执行文件,您可以从powershell本机执行(使用调用操作符
&
):

Invoke命令-ComputerName$SourceSrv-ScriptBlock{
&“$using:SourcePath\Bin\svc.exe”“-service='install,svc1,$using:SvcUser,,,M”
}

如果命令中没有它,为什么要使用它?另外:您不需要调用cmd.exe,可以直接从powershell调用可执行文件。最后但并非最不重要的一点是:复制过去的错误会有帮助。
cmd可能会将这些字符视为重定向操作符,并尝试将文件内容拉入上一个命令命令。您需要从cmd中转义。PowerShell不太确定。@马特·PowerShell或cmd可能正在删除引号,但在这样一个过于复杂的问题中很难分辨。@1确实不正确。但尝试从cmd中转义可能会得到更多信息。@vrdse我不知道这些引号在po中被解释为html链接st框。我已经编辑了原始博文,这很有帮助。现在,当解析器解释字符并在每一面添加另一个字符时。我如何避免这种情况发生?
-service='install,mucs,User,,,M'
@soad122您的
$svcpwd
变量是否已经有这些字符了?不,它们在cmd中是文本,我想是只能将它们作为变量的一部分。请尝试嵌入引号:
“`”…“
Regular Command which runs fine - \bin\svc.exe -service='install,scv1,UserName <Pwd>,,,M'
 Invoke-Command -ComputerName $SourceSrv -ScriptBlock { cmd.exe /c "$Using:SourcePath\Bin\svc.exe -service='install,svc1, $Using:SvcUser <$Using:SvcPwd>,,,M' " }
Invoke-Command -ComputerName $SourceSrv -ScriptBlock {
    & "$using:SourcePath\Bin\svc.exe" "-service='install,svc1, $using:SvcUser <$using:SvcPwd>,,,M'"
}