To run PowerShell as an administrator in UiPath, you can use the “Start Process” activity and pass the required arguments to it. Here’s how you can do it:
-
Add the “Start Process” activity to your UiPath workflow.
-
In the “FileName” property of the activity, enter “powershell.exe” to start the PowerShell application.
-
In the “Arguments” property, enter the following command to run PowerShell as an administrator:
-Command "& {Start-Process PowerShell -Verb RunAs}"
This command starts a new PowerShell process with elevated privileges.
- Optionally, you can set the “WorkingDirectory” property to the directory where you want the PowerShell process to start.
Here’s an example workflow to help you understand better:
In this example, the workflow starts PowerShell as an administrator and runs the “Get-Process” cmdlet to retrieve information about the currently running processes. The output is then displayed in a message box.
Note that when you run PowerShell as an administrator, you may be prompted to provide administrator credentials