Powershell script failing on Production

ack
Tera Contributor

Hello ALL, 

 

I am working on one automation that we placed poweshell script on MID server and calling from catalog and build using flow designer .

 

I had completed on dev instance and got the correct output and then moved to Prod. Now Prod , automation is failing getting error saying " Sub flow error" with below logs.

 

ack_0-1743601146658.png

 

Can anyone please help me to fix or At least give me some suggestions where to find and what type of error this is.

 

thanks in advance. 

 

3 REPLIES 3

Luiz Lucena
Mega Sage

Hi @ack 

I've been working with PowerShell and Orchestration for years now, dealing with all types of situation, I didn't face the one you did, but I can suggest few things (if is not done yet).

In all your PowerShell scripts, would be good to add this line at the end of them:

$Error | %{$This = $_; Write-Host $This.invocationInfo.scriptlinenumber $This.Exception.Message}

This will capture any failure in the PS script and show in the output with the line number that failed.

You can also grab the MID Server logs and dig deeper in it to find more information as well, if any.

LuizLucena_0-1743603470654.png


You should also confirm the credentials being used in PRD has the appropriate permissions to run the PowerShell script.

If I remember anything else I'll put here.

ack
Tera Contributor

@Luiz Lucena ,

 

Thank you for quick response.

 

I forgot to mention that The PowerShell script is working and giving the output when we run it from the MID sever standalone and while running from catalog , it giving the above error. 

Oh, ok. 
In your DEV environment, did it work from the Flow or by testing the script directly in the MID server?
Make sure your PRD MID Server has the appropriate capabilities enabled. 

Make sure also the checkbox Use Attachment is checked in your PS script file in the instance, also ensure all variables needed by the script is being passed in Flow.
The example below is from one of the flows we have that uses PS scripts.
EDIT: For this, we created an Action that is called from the Flow, you need to pass all PS variables needed in the Flow and the Action.

Screenshot 2025-04-02 at 11.00.11.png

Feel free to provide screenshot of your settings, just make sure to not show any company info.