Can't figure out why my variable in my PowerShell script keeps saying the variable is null (Error: The variable '$' cannot be retrieved because it has not been set.)
Mule Flow = HTTP --> Set Payload --> PowerShell --> Logger --> End
~ MULE XML Code Snippet - Using PowerShell Connector 3.x version ~
<powershell:execute config-ref="PowerShell" doc:name="PowerShell" scriptFile="classpath:powershell-script.ps1">
<powershell:parameters>
<powershell:parameter key="variable1">#[groovy: payload.variable1 ?: '']</powershell:parameter>
<powershell:parameter key="variable2">#[groovy: payload.variable2 ?: '']</powershell:parameter>
<powershell:parameter key="variable3">#[groovy: payload.variable3 ?: '']</powershell:parameter>
<powershell:parameters>
<powershell:execute>
~ PowerShell Code ~
Set-StrictMode -Version Latest
Param($variable1, $variable2, $variable3)
#Create NEW AD accounts
Function Start-Commands
{
Write-Output "Start-Commands"
Write-Output "Parameters-: $variable1 - $variable2 - $variable3"
}
Start-Commands
~ Console Output ~
Root Exception stack trace: org.mule.modules.powershell.PowershellException: The message could not be sent. An exception has been thrown: [{"Exception":"System.Management.Automation.RuntimeException: The variable '$flowVarManager' cannot be retrieved because it has not been set.\r\n