如何通过CFExecute参数将变量传递到powershell脚本?

如何通过CFExecute参数将变量传递到powershell脚本?,powershell,iis,coldfusion,cfexecute,Powershell,Iis,Coldfusion,Cfexecute,我正在尝试使用以下代码将用户提供的值传递到PowerShell脚本中,但运气不佳: <cfset MyVar="Woila!"> <cfoutput> <cfexecute name="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" arguments="$MyVar = #MyVar# C:\Users\raimonds\Desktop\create_website_IIS_aws_uat

我正在尝试使用以下代码将用户提供的值传递到PowerShell脚本中,但运气不佳:

<cfset MyVar="Woila!">

<cfoutput>
<cfexecute name="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" 

arguments="$MyVar = #MyVar# C:\Users\raimonds\Desktop\create_website_IIS_aws_uat_1.ps1" 
/>
</cfoutput>

参数写入PowerShell命令行,但它没有使用以下语法将变量传递到.ps1脚本中
$MyVar

试试看

<cfexecute name="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" arguments="-file C:\Users\raimonds\Desktop\create_website_IIS_aws_uat_1.ps1 ""youvalue"""/>

你的电脑就快到了。只需更改顺序,如下所示:

<cfset MyVar="Woila!">

<cfexecute name="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" 

arguments="C:\Users\raimonds\Desktop\create_website_IIS_aws_uat_1.ps1 
 MyVar '#MyVar#'" />
这假设脚本以通常的方式定义参数MyVar,例如:

 param([string]$MyVar)

看看这个你可能想用的

非常奇怪,但第二个答案是正确的,双引号。非常感谢!另外,不需要在
中包装
标记。标签内的CF变量将自动计算。
 param([string]$MyVar)