I am trying to run a PowerShell script in Flow Designer action

TBharati
Tera Contributor

I have created a MID Server script file and used the 'PowerShell' step in Flow Designer. I have set up a connection alias, too. But when I run a test on it, it gives an error- Invalid invocation: 'PowerShell execution requires MID'

What exactly is MID, and how can I set it up for my PowerShell script?

 

Thanks. 

3 REPLIES 3

Sathya10
Tera Expert

Please check if the credential being used has "Use MID Server" checked and the "MID Selection" is chosen as per your environment setup

Nikhil Bajaj9
Tera Sage

Hi @TBharati ,

 

Possible reasons for this error include:

  • MID Server Unavailability or Misconfiguration:

The MID Server might be offline, not properly configured, or not reachable from the ServiceNow instance.

  • Incorrect PowerShell Path:

The mid.powershell.path parameter on the MID Server might be incorrectly configured, pointing to a non-existent or incorrect path for the PowerShell executable.

  • PowerShell Execution Policy Restrictions:

The PowerShell execution policy on the MID Server host might be set to a restrictive level (e.g., AllSigned or RemoteSigned) that prevents the execution of unsigned scripts, which can be the case for scripts triggered by ServiceNow. Setting it to Unrestricted is often a workaround, though it has security implications.

  • PowerShell Version Incompatibility:

The PowerShell version on the MID Server might not meet the minimum requirements for the specific operation being attempted (e.g., requiring PowerShell 2.0 or greater).

  • Credential or Permission Issues:

The credentials used by the MID Server to execute PowerShell commands on the target system might be invalid or lack the necessary permissions.

 

If my answer helepd you, please mark it solution accepted.

 

Regards,

Nikhil Bajaj

Please appreciate my efforts, help and support extended to you by clicking on – “Accept as Solution”; button under my answer. It will motivate me to help others as well.
Regards,
Nikhil Bajaj

OlaN
Giga Sage
Giga Sage

Hi, 

Do you have a MID server set up and connected to your instance ?