Invoke PowerShell Activity Works On Windows Legacy But It Does Not Work In Windows Compatibility Projects

Resolution when the Invoke PowerShell activity works on Windows Legacy, but it does not work in Windows compatibility projects.

Issue Description: Error is thrown while running a Python script using Invoke Power Shell in UiPath. Same script runs successfully on Windows Legacy projects and from local PowerShell 32 and 64 runs, but it fails when it s run with Windows compatibility project.

Resolution: When running a script via Invoke PowerShell, before the Invoke Python script activity, that will non-persistently modify the execution policy for Microsoft.PowerShell.SDK 7.1, fixes the issue:

$A = Set-ExecutionPolicy Unrestricted -Scope Process

$C = Get-ExecutionPolicy -List

Out-String -InputObject $C -Width 100

What is this?

I’m experiencing the same problem: Invoke Power Shell doesn’t work for me after converting a project from Windows-Legacy to Windows. The error is the generic “Invoka Power Shell: The term ‘XXXXXXXXXXXXXXXX’ is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.”, but the term is the same that’s working in the “legacy” version of the project.

The “resolution” text is not understandable; it mentions something about a “Invoke Python” activity, and then the rest is written in poor English.

Can you please clarify?

I tried executing what you said prior to the PowerShell command that’s not being recognized, and in fact the output of that one is ok, but then the error still happens.

For anyone looking at the above article, please also have a look at this post:

It offers an additional workaround that should work for all cases.

The “workaround” is not working for me, no matter what I attempt, or either I don’t know how to call it with the proper syntax. Look at the attached screenshot.

Captura de pantalla 2023-10-23 122323