You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: support/power-platform/power-automate/desktop-flows/failed-to-run-powershell-script-error.md
+9-11Lines changed: 9 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,18 @@
1
1
---
2
-
title: Failed To Run PowerShell Script Error
2
+
title: Failed to Run PowerShell Script Error
3
3
description: Solves an error that occurs when you run the Run PowerShell script action in a desktop flow in Microsoft Power Automate for desktop.
4
4
ms.author: iomavrid
5
5
author: yiannismavridis
6
6
ms.custom: sap:Desktop flows
7
-
ms.date: 04/16/2025
7
+
ms.date: 04/18/2025
8
8
---
9
9
# "Failed to run PowerShell script" error when running the Run PowerShell script action
10
10
11
11
This article provides a resolution for an error that occurs when running the [Run PowerShell script](/power-automate/desktop-flows/actions-reference/scripting#runpowershellscript) action in Microsoft Power Automate for desktop.
12
12
13
13
## Symptoms
14
14
15
-
During the execution of a desktop flow in Power Automate for desktop, an error occurs message when running the **Run PowerShell script** action. This issue might also occur after a recent Windows update.
15
+
During the execution of a desktop flow in Power Automate for desktop, an error occurs when running the **Run PowerShell script** action. This issue might also occur after a recent Windows update.
16
16
17
17
The error message appears as follows:
18
18
@@ -27,12 +27,12 @@ Microsoft.Flow.RPA.Desktop.Modules.SDK.ActionException: Failed to run PowerShell
27
27
28
28
## Cause
29
29
30
-
The **Run PowerShell script** action internally starts an instance of `powershell.exe` and provides the script specified in the action's input as an argument to the process. If the system fails to find `powershell.exe`, you might receive the error message.
30
+
The **Run PowerShell script** action internally starts an instance of `powershell.exe` and provides the script specified in the action's input as an argument for the process. If the system fails to find `powershell.exe`, you might receive the error message.
31
31
32
32
The most likely cause of this issue is that the **Path** environment variable doesn't include the directory containing the `powershell.exe` executable. To confirm this as the root cause, follow these steps:
33
33
34
34
1. Open a Command Prompt (CMD) window.
35
-
1. Run `powershell.exe` by typing the command and pressing Enter.
35
+
1. Run `powershell.exe` by typing the command and pressing **Enter**.
36
36
37
37
If the following message occurs, then the issue lies in the missing path to `powershell.exe` in the **Path** environment variable.
38
38
@@ -42,19 +42,17 @@ If the following message occurs, then the issue lies in the missing path to `pow
42
42
43
43
To resolve this issue, follow these steps to update the **Path** environment variable to include the directory of the `powershell.exe` executable:
44
44
45
-
1. Open the Start menu and search for "Environment Variables." Select**Edit the system environment variables**.
45
+
1. Open the Start menu, search for **Environment Variables**, and then select**Edit the system environment variables**.
46
46
47
47
1. In the **System Properties** window, select **Environment Variables**.
48
48
49
-
1. Under the **System variables** section, locate and select the **Path** variable, then select **Edit**.
49
+
1. Under the **System variables** section, locate and select the **Path** variable, and then select **Edit**.
50
50
51
51
1. Add the directory path of `powershell.exe` to the list of paths.
52
52
53
-
In most cases, the missing path is:**C:\WINDOWS\System32\WindowsPowerShell\v1.0\\**
53
+
In most cases, the missing path is **C:\WINDOWS\System32\WindowsPowerShell\v1.0\\**.
54
54
55
-
To confirm the correct path, open a PowerShell terminal and run the following command:
56
-
57
-
`$PsHome`
55
+
To confirm the correct path, open a PowerShell terminal and run the `$PsHome` command
58
56
59
57
Use the displayed path as the value to add to the **Path** variable.
0 commit comments