我试图使用以下代码将用户提供的值传递给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命令行中,但是它没有用这个语法$MyVar将变量传递到.ps1脚本中。
发布于 2016-11-26 09:31:45
试试看
<cfexecute name="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" arguments="-file C:\Users\raimonds\Desktop\create_website_IIS_aws_uat_1.ps1 ""youvalue"""/>发布于 2016-11-27 13:20:02
你差点就到了。只需更改顺序,如下所示:
<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#'" />或者,将参数属性定义为
arguments="& 'C:\Users\raimonds\Desktop\create_website_IIS_aws_uat_1.ps1'
MyVar '#MyVar#'"这假设脚本按照通常的方式定义参数MyVar,例如:
param([string]$MyVar)查看您可能希望使用的这个Stackoverflow page for additional Powershell options。
https://stackoverflow.com/questions/40813973
复制相似问题