Why is it not possible to run a PowerShell script from UiPath Studio?
Issue Description: If there are issues encountered when running scripts from UiPath Studio, it could be due to execution policy restrictions. This knowledge base article provides a technical solution to identify and resolve execution policy-related issues to enable successful script execution from UiPath Studio.
Resolution:
- Check Execution Policies
To begin troubleshooting, compare the execution policies affecting Studio's execution and those on the local machine. Follow the steps below:
- Open PowerShell in UiPath Studio.
- Execute the following command:
PowerShell Command
$C = Get-ExecutionPolicy -List
Out-String -InputObject $C -Width 100
- This command retrieves the execution policies and stores them in the variable $C.
- Review the output to see the execution policies for different scopes such as MachinePolicy, UserPolicy, Process, CurrentUser, and LocalMachine.
- Compare the execution policy for Studio's execution (Process) with the policies on the local machine. Pay attention to any differences that may be relevant to the issue being experienced.
- Update Execution Policy (if necessary)
If the execution policy for Studio's execution is undefined or differs from the local machine, modify it to "Unrestricted" using the following command,
- PowerShell Command <Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process>
This command sets the execution policy for the current process (UiPath Studio) to "Unrestricted," allowing scripts to run without restrictions.
Note: Changing the execution policy should be done with caution, as it may have security implications. Ensure that the the risks associated with setting the policy to "Unrestricted" are understood and consider following the organization's security policies or consulting the IT department.