Skip to content

Commit 1695642

Browse files
authored
Merge pull request #8792 from MicrosoftDocs/main
Auto push to live 2025-04-24 10:02:57
2 parents f2ed1b5 + c9a159f commit 1695642

File tree

9 files changed

+534
-65
lines changed

9 files changed

+534
-65
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: Failed to Run PowerShell Script Error
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+
ms.author: iomavrid
5+
author: yiannismavridis
6+
ms.custom: sap:Desktop flows
7+
ms.date: 04/24/2025
8+
---
9+
# "Failed to run PowerShell script" error when running the Run PowerShell script action
10+
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+
13+
## Symptoms
14+
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+
17+
The error message appears as follows:
18+
19+
```output
20+
Microsoft.Flow.RPA.Desktop.Modules.SDK.ActionException: Failed to run PowerShell script. ---> System.ComponentModel.Win32Exception: The system cannot find the file specified
21+
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
22+
at Microsoft.Flow.RPA.Desktop.Modules.System.Actions.SystemActions.RunPowershellScript(Variant powershellCode, Variant& scriptStandardOutput, Variant& scriptErrorOutput)
23+
--- End of inner exception stack trace ---
24+
at Microsoft.Flow.RPA.Desktop.Modules.System.Actions.RunPowershellScript.Execute(ActionContext context)
25+
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)
26+
```
27+
28+
## Cause
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 for the process. If the system fails to find `powershell.exe`, you might receive the error message.
31+
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 is the root cause, follow these steps:
33+
34+
1. Open a Command Prompt (CMD) window.
35+
1. Run `powershell.exe` by typing the command and pressing **Enter**.
36+
37+
If the following message occurs, then the issue lies in the missing path to `powershell.exe` in the **Path** environment variable.
38+
39+
> 'powershell.exe' is not recognized as an internal or external command, operable program or batch file.
40+
41+
## Resolution
42+
43+
To resolve this issue, follow these steps to update the **Path** environment variable to include the directory of the `powershell.exe` executable:
44+
45+
1. Open the Start menu, search for **Environment Variables**, and then select **Edit the system environment variables**.
46+
47+
1. In the **System Properties** window, select **Environment Variables**.
48+
49+
1. Under the **System variables** section, locate and select the **Path** variable, and then select **Edit**.
50+
51+
1. Add the directory path of `powershell.exe` to the list of paths.
52+
53+
In most cases, the missing path is **C:\WINDOWS\System32\WindowsPowerShell\v1.0\\**.
54+
55+
To confirm the correct path, open a PowerShell terminal and run the `$PsHome` command.
56+
57+
Use the displayed path as the value to add to the **Path** variable.
58+
59+
1. Select **OK** to save changes and close all dialogs.
Loading
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Take Screenshot Action Fails in Unattended Mode
3+
description: Resolves an error that occurs in the Take screenshot action when you run an unattended desktop flow in Microsoft Power Automate for desktop.
4+
ms.author: iomavrid
5+
author: yiannismavridis
6+
ms.custom: sap:Desktop flows\Unattended flow runtime errors
7+
ms.date: 04/24/2025
8+
---
9+
# Unattended desktop flow run fails with the "Failed to take screenshot" error
10+
11+
This article provides a resolution for an error that occurs in the [Take screenshot](/power-automate/desktop-flows/actions-reference/workstation#takescreenshotbase) action when running an unattended desktop flow in Microsoft Power Automate for desktop.
12+
13+
## Symptoms
14+
15+
The **Take screenshot** action fails with the following error message:
16+
17+
```output
18+
Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.ActionException: Failed to take screenshot. ---> System.ComponentModel.Win32Exception: The handle is invalid
19+
at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)
20+
at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize)
21+
at Microsoft.Flow.RPA.Desktop.Modules.System.Actions.SystemActions.TakeScreenShot(Variant fileName, Variant screenToCapture, Int32 screenCaptureOption, Boolean copyToClipboard, Int32 fileFormat)
22+
--- End of inner exception stack trace ---
23+
at Microsoft.Flow.RPA.Desktop.Modules.System.Actions.TakeScreenshotBase.Execute(ActionContext context)
24+
at Microsoft.Flow.RPA.Desktop.Robin.Engine.Execution.ActionRunner.Run(IActionStatement statement, Dictionary`2 inputArguments, Dictionary`2 outputArguments)
25+
```
26+
27+
## Cause
28+
29+
The issue occurs due to a specific security policy that impacts how a User Account Control (UAC) window (for administrative privileges) is prompted. This policy prevents the flow from accessing the screen and capturing the screenshot.
30+
31+
## Resolution 1: Locate and allow binaries except for non-Windows ones to run without elevation prompt
32+
33+
To solve this issue:
34+
35+
1. In Local Group Policy Editor, go to **Computer Configuration** > **Windows Settings** > **Security Settings** > **Local Policies** > **Security Options**.
36+
1. Locate the **User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode** security policy setting.
37+
1. Set the value to **Prompt for consent for non-Windows binaries**.
38+
39+
:::image type="content" source="media/take-screenshot-action-fails-in-unattended-mode/local-security-policy.png" alt-text="Screenshot of the User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode setting in the Local Security Policy window." lightbox="media/take-screenshot-action-fails-in-unattended-mode/local-security-policy.png":::
40+
41+
For more information about the best practices, location, values, policy management and security considerations for the security policy setting, see [User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode](/previous-versions/windows/it-pro/windows-10/security/threat-protection/security-policy-settings/user-account-control-behavior-of-the-elevation-prompt-for-administrators-in-admin-approval-mode).
42+
43+
## Resolution 2: Change the registry key
44+
45+
Modify the registry key to adjust the UAC behavior:
46+
47+
- Hive: **HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System**
48+
- Registry key name: [ConsentPromptBehaviorAdmin](/windows/security/application-security/application-control/user-account-control/settings-and-configuration?tabs=reg#user-account-control-configuration)
49+
- Type: DWORD
50+
- Value: **5**
51+
52+
Options for the **ConsentPromptBehaviorAdmin** key:
53+
54+
- **0** = Elevate without prompting
55+
- **1** = Prompt for credentials on the secure desktop
56+
- **2** = Prompt for consent on the secure desktop
57+
- **3** = Prompt for credentials
58+
- **4** = Prompt for consent
59+
- **5** (Default) = Prompt for consent for non-Windows binaries. Set the registry key to this value.
60+
61+
## More information
62+
63+
[User Account Control settings and configuration](/windows/security/application-security/application-control/user-account-control/settings-and-configuration)

support/power-platform/power-automate/toc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@
160160
href: desktop-flows/troubleshoot-excel-errors.md
161161
- name: Errors when running attended or unattended desktop flows
162162
href: desktop-flows/troubleshoot-errors-running-attended-or-unattended-desktop-flows.md
163+
- name: '"Failed to run PowerShell script" error'
164+
href: desktop-flows/failed-to-run-powershell-script-error.md
165+
- name: '"Failed to take screenshot" error in unattended desktop flow run'
166+
href: desktop-flows/take-screenshot-action-fails-in-unattended-mode.md
163167
- name: Failed connection between Power Automate components
164168
href: desktop-flows/failed-connection-between-power-automate-components.md
165169
- name: Failed license check on a desktop flow run

support/windows-server/active-directory/active-directory-domain-join-troubleshooting-guidance.md

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,11 @@ For more information, see [Error code 0x569: The user has not been granted the r
5757

5858
### Error code 0x6BF or 0xC002001C
5959

60-
> The remote procedure call failed and did not execute.
61-
62-
Here's an example from the *netsetup.log* file:
63-
64-
```output
65-
mm/dd/yyyy hh:mm:ss:ms NetpGetLsaHandle: LsaOpenPolicy on \\<DC name>.<domain>.<tld> failed: 0xc002001c
66-
mm/dd/yyyy hh:mm:ss:ms NetpGetLsaPrimaryDomain: status: 0xc002001c
67-
mm/dd/yyyy hh:mm:ss:ms NetpJoinDomain: initiaing a rollback due to earlier errors
68-
mm/dd/yyyy hh:mm:ss:ms NetpJoinDomain: status of disconnecting from '\\<DC name>.<domain>.<tld>': 0x0
69-
mm/dd/yyyy hh:mm:ss:ms NetpDoDomainJoin: status: 0x6bf
70-
```
71-
72-
This error occurs when a network device (router, firewall, or VPN device) rejects network packets between the client being joined and the DC.
73-
74-
Make sure of the following items:
75-
76-
- Verify the connectivity between the client being joined and the target DC over the required ports and protocols.
77-
- Disable bind time feature negotiation.
78-
- Disable TCP Chimney Offload and IP offload.
60+
For more information, see [Status code 0x6bf or 0xc002001c: The remote procedure call failed and did not execute](status-code-0x6bf-0xc002001c.md).
7961

8062
### Error code 0x6D9
8163

82-
See [Domain join error 0x6D9 "There are no more endpoints available from the endpoint mapper"](./domain-join-error-0x6d9-there-are-no-more-endpoints-available-from-the-endpoint-mapper.md) for troubleshooting guide.
64+
See [Domain join error 0x6D9 "There are no more endpoints available from the endpoint mapper"](./domain-join-error-0x6d9-there-are-no-more-endpoints-available-from-the-endpoint-mapper.md) for troubleshooting guide.
8365

8466
### Error code 0xa8b
8567

@@ -91,50 +73,7 @@ For more information, see [Domain join error 0x40 "The specified network name is
9173

9274
### Error code 0x54b
9375

94-
:::image type="content" source="media/active-directory-domain-join-troubleshooting-guidance/error-0x54b-message.png" alt-text="Screenshot of the dialog box showing the error message for error code 0x54b.":::
95-
96-
Here's an example of the error message:
97-
98-
> Note: This information is intended for a network administrator. If you are not your network's administrator, notify the administrator that you received this information, which has been recorded in the file C:\WINDOWS\debug\dcdiag.txt.
99-
>
100-
> The following error occurred when DNS was queried for the service location (SRV) resource record used to locate an Active Directory Domain Controller (AD DC) for domain "<domain_name>":
101-
>
102-
> The error was: "This operation returned because the timeout period expired."
103-
> (error code 0x000005B4 ERROR_TIMEOUT)
104-
>
105-
> The query was for the SRV record for <srv_record>
106-
>
107-
> The DNS servers used by this computer for name resolution are not responding. This computer is configured to use DNS servers with the following IP addresses:
108-
>
109-
> <ip_address>
110-
>
111-
> Verify that this computer is connected to the network, that these are the correct DNS server IP addresses, and that at least one of the DNS servers is running.
112-
113-
Here's an example from the *netsetup.log* file:
114-
115-
```output
116-
mm/dd/yyyy hh:mm:ss:ms NetpValidateName: checking to see if '<domain_name>' is valid as type 3 name
117-
mm/dd/yyyy hh:mm:ss:ms NetpCheckDomainNameIsValid for <domain_name> returned 0x54b, last error is 0x0
118-
mm/dd/yyyy hh:mm:ss:ms NetpCheckDomainNameIsValid [ Exists ] for '<domain_name>' returned 0x54b
119-
```
120-
121-
To resolve the 0x54b error, follow these steps:
122-
123-
- Check the network connectivity between the client and the Domain controller.
124-
- Verify if the Preferred DNS Server is the correct DNS Server.
125-
- Run `nltest /dsgetdc` (DC Discovery) to verify if you can discover a DC.
126-
127-
For example:
128-
129-
```console
130-
nltest /dsgetdc:<domain_name> /force
131-
```
132-
133-
Expected Output:
134-
135-
:::image type="content" source="media/active-directory-domain-join-troubleshooting-guidance/nltest-output.png" alt-text="Screenshot that shows the nltest command output.":::
136-
137-
- Run `DCDiag /v` on the closest domain controller and verify if SRV records are registered. For example: `_ldap._tcp.dc._msdcs.<domain_name>.com`.
76+
For more information, see [Domain join error code 0x54b](error-code-0x54b.md).
13877

13978
### Error code 0x0000232A
14079

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
---
2+
title: Domain Join Error Code 0x54b
3+
description: Provides troubleshooting steps for resolving error code 0x54b when you join a workgroup computer to a domain.
4+
ms.date: 04/23/2025
5+
manager: dcscontentpm
6+
audience: itpro
7+
ms.topic: troubleshooting
8+
ms.reviewer: eriw,dennhu,herbertm
9+
ms.custom:
10+
- sap:active directory\on-premises active directory domain join
11+
- pcy:WinComm Directory Services
12+
---
13+
# Domain join error code 0x54b
14+
15+
This article provides troubleshooting steps for resolving error code 0x54b when you join a workgroup computer to a domain.
16+
17+
## Symptoms
18+
19+
When you join a workgroup computer to a domain, you receive the following error message:
20+
21+
> **Error code 0x54b**
22+
>
23+
> Computer Name/Domain Changes
24+
>
25+
> An Active Directory Domain Controller (AD DC) for the domain "\<NetBIOS\\_name>" could not be contacted.
26+
>
27+
> Ensure that the domain name is typed correctly.
28+
>
29+
> If the name is correct, click Details for troubleshooting information.
30+
>
31+
> Note: This information is intended for a network administrator. If you are not your network's administrator, notify the administrator that you received this information, which has been recorded in the file C:\WINDOWS\debug\dcdiag.txt.
32+
>
33+
> The following error occurred when DNS was queried for the service location (SRV) resource record used to locate an Active Directory Domain Controller (AD DC) for domain "\<domain\_name>":
34+
>
35+
> The error was: "This operation returned because the timeout period expired." (error code 0x000005B4 ERROR\_TIMEOUT)
36+
>
37+
> The query was for the SRV record for \<srv\_record>
38+
>
39+
> The DNS servers used by this computer for name resolution are not responding. This computer is configured to use DNS servers with the following IP addresses:
40+
> \<ip\_address>
41+
>
42+
> Verify that this computer is connected to the network, that these are the correct DNS server IP addresses, and that at least one of the DNS servers is running.
43+
44+
Here's an example from the **netsetup.log** file:
45+
46+
```output
47+
NetpValidateName: checking to see if '<domain_name>' is valid as type 3 name
48+
NetpCheckDomainNameIsValid for <domain_name> returned 0x54b, last error is 0x0
49+
NetpCheckDomainNameIsValid [ Exists ] for '<domain_name>' returned 0x54b
50+
```
51+
52+
## Cause
53+
54+
Error code 0x54b means "ERROR\_NO\_SUCH\_DOMAIN." This error code indicates the specified domain can't be contacted, pointing to issues locating domain controllers (DCs).
55+
56+
* Domain Name System (DNS) times out and resolution fails when attempting to reach DCs.
57+
* Network connectivity to DCs is blocked on TCP port 135, 389, 445, or RPC dynamic ports.
58+
59+
## Troubleshooting steps
60+
61+
To resolve the 0x54b error, follow these steps:
62+
63+
### Step 1: Check the network connectivity between the client and the DC
64+
65+
| Server port | Service |
66+
| --------------- | ------------------- |
67+
| TCP 135 | RPC Endpoint Mapper |
68+
| TCP 49152-65535 | RPC Dynamic Ports |
69+
| TCP 445 | SMB |
70+
| UDP/TCP 389 | LDAP |
71+
72+
* Refer to the list of required ports in [How to configure a firewall for Active Directory domains and trusts](config-firewall-for-ad-domains-and-trusts.md).
73+
74+
* Use the `Test-NetConnection` command to test the connection between DCs:
75+
76+
```powershell
77+
Test-NetConnection <IP\_address\_of\_the\_DC> -Port 389
78+
79+
ComputerName: <computer_name>
80+
RemoteAddress: <remote_address>
81+
RemotePort: 389
82+
InterfaceAlias: Ethernet 2
83+
SourceAddress: <source_address>
84+
TcpTestSucceeded : True
85+
```
86+
87+
It indicates that the LDAP port TCP 389 is open between the client and the DC.
88+
89+
* [PortQry Command Line Port Scanner Version 2.0](https://www.microsoft.com/download/details.aspx?id=17148) can also be used to identify if a port (TCP/UDP) is blocked on DCs. Here's an example syntax:
90+
91+
```console
92+
portqry -n <problem_server> -e 135
93+
portqry -n <problem_server> -e 445
94+
portqry -n <problem_server> -e 389
95+
portqry -n <problem_server> -p UDP -e 389
96+
portqry -n <problem_server> -r 49152:65535
97+
```
98+
99+
Port query output examples:
100+
101+
* When the connection to TCP port 135 on a DC is blocked, the following message is displayed:
102+
103+
```console
104+
portqry -n <dc_name> -e 135
105+
106+
Querying target system called:
107+
108+
<dc_name>
109+
110+
Attempting to resolve name to IP address...
111+
112+
Name resolved to <ip_address>
113+
114+
querying...
115+
116+
TCP port 135 (epmap service):FILTERED
117+
```
118+
119+
* When the connection to TCP port 389 on a DC is successful, the following message is displayed:
120+
121+
```console
122+
portqry -n <dc_name> -e 389
123+
124+
Querying target system called:
125+
126+
<dc_name>
127+
128+
Attempting to resolve name to IP address...
129+
130+
Name resolved to 192.168.1.2
131+
132+
querying...
133+
134+
TCP port 389 (ldap service): LISTENING
135+
```
136+
137+
* Collect network monitor traces when reproducing the issue to confirm if there's any network connectivity issue, if necessary.
138+
139+
### Step 2: Verify if the preferred DNS server is the correct DNS server
140+
141+
### Step 3: Verify if the DC can be discovered
142+
143+
Run `nltest /dsgetdc` (DC Discovery) to verify if you can discover a DC. For example:
144+
145+
```console
146+
nltest /dsgetdc:<domain_name> /force
147+
148+
DC: \\<dc_address>
149+
Address: \\<dc_address>
150+
Dom Guid: <dom_guid>
151+
Dom Name: <dom_name>
152+
Forest Name: <foreast_name>
153+
Dc Site name: Default-First-site-Name
154+
Our Site Name: Default-First-site-Name
155+
Flags: PDC GC DS LDAP KDC TIMESERV WRITABLE DNS_DC DNS_DOMAIN DNS_FOREST CLOSE_SITE FULL_SECRET WS DS_8 DS_9 DS_10 KEYLIST
156+
The command completed successfully
157+
```
158+
159+
### Step 4: Verify if SRV records are registered
160+
161+
Run `DCDiag /v` on the closest DC and verify if SRV records are registered. For example:
162+
163+
`_ldap._tcp.dc._msdcs.<domain_name>.com.`

0 commit comments

Comments
 (0)