Not able to run PowerShell script with scp cmdlet

Trying to transfer file from one system to another vm using below power shell script

scp-r $sourcefilepath abc.bcd@111.11.11.11:$destpath
$password

Getting error scp is not recognized as the name of cmdlet

Please help to resolve this issue

Hello @Manuthejusui

Is it throwing in UiPath or have you tried with any IDE?

Thanks

In UiPath, working fine in ide

Hope you are using the invoke powershell activity. Have you enabled IsScript in the property?

Thanks

Yes i have enabled IsScript

Are you facing the same issue in Windows Legacy and Windows projects?

When i run using windows PowerShell not getting error only when i run in UiPath invoke PowerShell getting this error

I am referring to the UiPath Studio project compatibility

image

In UiPath Studio, if you are using a Windows project, you have a built-in Microsoft.PowerShell.SDK version in the UiPath.System.Activities version


Try this possible solution:

Adapt the policy at the start of your script, i.e. like so:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process

Check this explanation Invoke powershell unable to recognized aws keyword - #12 by jeevith

Hi @marian.platonov

I’m using windows legacy and still getting same error i also in co-orporated the cmd at the start of the script

Can you open your powershell.exe console and run this command and provide a screenshot?

Get-ExecutionPolicy -List

When you are executing the code from UiPath, normally it will be executed with the Process ExecutionPolicy, but over it, MachinePolicy and UserPolicy are taking precedence.

You can try also to add in your code at the beginning, this line:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process

Yes i have added the command provided by you and please find the screen shot you required for in the attachment

I think we are not on the same page.

Check this solution (try to add these lines before you code)

Example:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process
...
scp-r $sourcefilepath abc.bcd@111.11.11.11:$destpath
$password...

@marian.platonov
Im trying to transfer file from one vm to another
New to PowerShell guide me if any error in script also. Please find the screen shots attached

Can someone help me with solution

Try this solution (first, it will read the ps1 script as text, then it will execute it, in the PowerShell script you will write the output to a text file, then to display the results, you will read the results text output and display the results in a log message):

PowerShell Windows.zip (136.8 KB)