将参数传递给Powershell
我有以下PS脚本:将参数传递给Powershell,powershell,biztalk,biztalk-deployment,btdf,Powershell,Biztalk,Biztalk Deployment,Btdf,我有以下PS脚本: function Install-BizTalkApplication { param( [Parameter(Position=0,Mandatory=$true,HelpMessage="Msi file should be existing")] [ValidateScript({Test-Path $_})] [Alias("msi")] [string]$MsiFile, [Parameter(Position=1,HelpMessage="
function Install-BizTalkApplication
{
param(
[Parameter(Position=0,Mandatory=$true,HelpMessage="Msi file should be existing")]
[ValidateScript({Test-Path $_})]
[Alias("msi")]
[string]$MsiFile,
[Parameter(Position=1,HelpMessage="Path wherein the resource file will be installed")]
[Alias("path")]
[string]$ApplicationInstallPath,
[Parameter(Position=2,Mandatory=$true,HelpMessage="Only valid parameters are Local,Dev,Test and Prod")]
[Alias("env")]
[ValidateSet("Local","Dev","Prod","Test")]
[string]$Environment,
[bool]$BTDeployMgmtDB=$true,
[bool]$SkipUndeploy=$true
)
我尝试使用Powershell ISE运行脚本,传递3个参数,如下所示:
BTDF\Sources\Deployment\BuildAndDeploy.ps1 -msi "C:\Builds\1\CIDemo2\CIDemo2 BTDF\Sources\Deployment\bin\Debug\CIDemo-1.0.0.msi" -ApplicationInstallPath "c:\program files (x86)\CIDemo" -Environment "Dev"
但我得到了以下错误:
The string starting:
At line:1 char:1
+ <<<< 'C:\Builds\1\CIDemo2\CIDemo2 BTDF\Sources\Deployment\BuildAndDeploy.ps1 -msi "C:\Builds\1\CIDemo2\CIDemo2 BTDF\Sources\Deployment\bin\Debug\CIDemo-1.0.0.msi" -ApplicationInstallPath "c:\program files
(x86)\CIDemo" -Environment "Dev"
is missing the terminator: '.
At line:1 char:233
开始的字符串:
第1行字符:1
+路径中有一个空格-C:\Builds\1\CIDemo2\CIDemo2 BTDF\Sources\Deployment\BuildAndDeploy.ps1
你必须引用它
按如下方式运行:
& 'C:\Builds\1\CIDemo2\CIDemo2 BTDF\Sources\Deployment\BuildAndDeploy.ps1' -msi "C:\Builds\1\CIDemo2\CIDemo2 BTDF\Sources\Deployment\bin\Debug\CIDemo-1.0.0.msi" -ApplicationInstallPath "c:\program files (x86)\CIDemo" -Environment "Dev"
我怀疑您达到了命令提示字符串长度限制。大概是255个字符。