Using Alternate Credentials with RunAs user mode results in WSMan service error

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 2 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
jmrusnak
Posts: 2
Last visit: Mon Jan 08, 2024 6:03 am

Using Alternate Credentials with RunAs user mode results in WSMan service error

Post by jmrusnak »

Product: PowerShell Studio 2021 (64 Bit)
Build: v5.8.192
OS: Windows 10 Enterprise (64 Bit)
Build: v10.0.19041.0
PS Version: 5.1.19041.1023

I have a simple script with a GUI front end that runs as me, it runs when I package to an EXE as me, or runs if I login as the Service Account and run it. It does not run when I put the "Run As Account" option in the Packager Build under alternate credentials, run mode - RunAs user. I have successfully used this option on other scripts.

On this script I get the following error when trying to use the RunAs user. The script works when I am logged in as the user, but not when running under another user account with this RunAs option. Here is the error:
[localhost] Connecting to remote server localhost failed with the following error message : The WSMan service could not launch a host process to process the given request. Make sure the WSMan provider host server and proxy are properly registered. For more information, see the about_Remote_Troubleshooting Help topic.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Using Alternate Credentials with RunAs user mode results in WSMan service error

Post by Alexander Riedel »

Apologies, but we cannot investigate or solve local permission problems.
Your problem is likely related to this:
https://devblogs.microsoft.com/powershe ... owershell/
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
jmrusnak
Posts: 2
Last visit: Mon Jan 08, 2024 6:03 am

Re: Using Alternate Credentials with RunAs user mode results in WSMan service error

Post by jmrusnak »

I appreciate your reply, but I am confused that I am getting this error because I am not using any ps remoting commands.

The only commands I am using in the script are:
Get-RDConnectionBrokerHighAvailability
Set-RDSessionCollectionConfiguration
Get-RDSessionCollectionConfiguration

The script works when I don't use the RunAs run mode under Output settings. When I add the RunAs user Run Mode, that's when I'm getting this error.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Using Alternate Credentials with RunAs user mode results in WSMan service error

Post by Alexander Riedel »

Once again, apologies, but we do not have access to your script, packaged or unpackaged, the profile of the user in question, your group policies, login scripts etc.
Your local event logs maybe of some more help. There is also PowerShell's script block logging, which would indicate if any PowerShell remoting commands are executed from somewhere.
Needless to say, we also do not have access to your event logs :D
Alexander Riedel
SAPIEN Technologies, Inc.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Using Alternate Credentials with RunAs user mode results in WSMan service error

Post by jvierra »

jmrusnak wrote: Fri Aug 13, 2021 11:30 am I appreciate your reply, but I am confused that I am getting this error because I am not using any ps remoting commands.

The only commands I am using in the script are:
Get-RDConnectionBrokerHighAvailability
Set-RDSessionCollectionConfiguration
Get-RDSessionCollectionConfiguration

The script works when I don't use the RunAs run mode under Output settings. When I add the RunAs user Run Mode, that's when I'm getting this error.
As you can see you are using remoting and local loopback as the article link from Alex references. The RD Connection manager is a remoting method which can use the loopback connector. Also various filters like AV net filters may force all remote connections through the loopback connector and the session broker is likely acquired by polling the fist time it is executed in a new user session.

There may even be more nuances to how the remote session is built so I suggest that you proceed by inspecting the patch.

Clearly the issue is not the code usage at least as you have described it. The PS engine you are using is the PowerShell host engine which is the same as PowerShell CLI with your script as the interface presentation and just some security wrappers and checks.

Good luck.
This topic is 2 years and 7 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.