powershellcoldfusioncoldfusion-11cfexecute

CFEXECUTE seems to not execute PowerShell in ColdFusion 11


Here is a sample:

<cfset cmd="get-date -format g" /> 
<cfset args="-inputformat none -Command " & cmd />
<cfoutput>
    <cfexecute name="powershell.exe" variable="result" errorvariable="err"
               arguments="#args#" timeout="99" />
    <p>Result: <cfif result neq "">#result#<cfelse>None</cfif></p>
    <p>Error: <cfif err neq "">#err#<cfelse>None</cfif></p>
</cfoutput>

On Windows 2008 R2 with ColdFusion 10, this will accurately put the PowerShell command's output into the result variable. After upgrading to ColdFusion 11, this code will execute with no errors but there is no result.

If I try some other command that will save a file or something, there is no evidence that the PowerShell command is even being executed.

I've tested against an upgraded ColdFusion 11, and by installing ColdFusion 11 fresh. In all cases, I'm using CF as a stand-alone server. I've tried with or without CF 11 updates/hotfixes. I've verified that the user account that CF is running as has permission to execute PowerShell.

Your help and/or corroboration of this problem is appreciated. What am I missing? If this is a bug, any ideas on how to execute some PowerShell commands from CF 11 moving forward?

Thanks for taking a look!


Solution

  • To folks facing this, see if the answer lies in updating the jvm that CF uses. By default, cf11 came (at least initially) with Java 1.8.0_25, which as I write in 2016 is dated.

    Try updating to a later jvm version. Pete Freitag has a nice video on doing it, and I point to it in a blog post dealing with challenges if you find CF won't start after trying this:

    http://www.carehart.org/blog/client/index.cfm/2014/12/11/help_I_updated_CFs_JVM_and_it_wont_start

    And let us know here if updating the jvm helps.