powershelliiscoldfusioncfexecute

How to pass variable into powershell script through CFExecute arguments?


I'm trying to pass a user supplied value into PowerShell script using the following code, but am having no luck:

<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>

The argument writes in the PowerShell command line, but it is not passing the variable into the .ps1 script with this syntax $MyVar.


Solution

  • try it

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