Invoke Power Shell: Exception calling "Open" with "0" argument(s):

This script is working on the same machine in Powershell ISE and but is not working while invoking the PS code in Studio

Error :
Invoke Power Shell: Exception calling “Open” with “0” argument(s): “The type initializer for ‘System.Data.SqlClient.TdsParser’ threw an exception.”

Screenshot of function in the Powershell script:

Do you have “is script” ticket in properties?

Also where do you get the variables like $DBServer from? Do you provide them from Invoke Powershell or where are they defined?

yes “is script” is enabled and passing the required input values as parameter in invoke powershell properties and also tried hardcoded the values inside script.

Required values are passing correctly to script

Hi @Sathish_Kumar_S and @iamNairda,

The Invoke PowerShell activity in some of the recent versions is broken.
UiPath Community 2022.12 Release - News / Release Notes - UiPath Community Forum

See here for an alternative to run your scripts using Start-Process. This may need additional workaround such that your PS script output can be consumed by the UiPath Runtime
Just trying to download a file from a website… this should be easy - Help / Activities - UiPath Community Forum

1 Like

I have discovered the same PS script works in Windows-Legacy project

It is not working in only in Windows compatibility project

Can you advice?

Screenshot for your ref

Try using the Start Process activity instead.

Example:

  1. Provide the local path of the powershell.exe that is working with your script or cmdlet.

  1. Provide the script location and set the process execution policy.

For a C# language

@"Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
C:\...\scripts\check_robot_service.ps1 | Out-File 'output.txt'"

  1. Add a delay for the process to finish its execution and save the file to output.txt

image

  1. Read Text File to see the response content

image

  1. Write Line to see the results.

image

Output sample:

image

Hi @marian.platonov
did Compatibility issue related to windows projects solved as i am facing the same issue now when I tried the same scenario in windows projects it gives me the same error but when create windows legacy project script working fine.
Note:
can not use start process activity as the Power shell script has no static time to make the delay.

Thanks in advance :slight_smile: