Clarification on RunAs and SetExecution

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

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 4 years and 9 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.
Locked
Wburlingame

Clarification on RunAs and SetExecution

Post by Wburlingame »

I am trying to gain a better understanding on what method to best us for Domain joined PC environment.

Whether I run the exe file without runas or with does make a difference but also some of my button commands does not output text but in pss it works.

Is there a way to run as bypass mode or as a service without permanently affecting pc SetExecution policy but only during app use?

I am having .msi denied permission error as well but I'll deal with that at another time. The EXE use seems like a better solution for our environment.

I have not completed getting any script signing yet either if that may be an issue as well.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Clarification on RunAs and SetExecution

Post by jvierra »

"RunAs" is used to elevate a process. "runas user" allows you to specify a specific user credential to run the exe.

Why you would use this depends on what you need to accomplish.

The rest of your questions are too vague to answer. Try asking one complete question at a time. Also try to understand that forums are not a good place to get personal training in how to use Windows or how to script. The forum format is not designed to support that. We can answer specific questions related to specific code.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Clarification on RunAs and SetExecution

Post by Alexander Riedel »

The execution policy on your machine applies only to scripts run directly from a PowerShell console (or the ISE). Other hosts may not evaluate this policy or not execute your code as a "script file".
Without any additional information we cannot know what "the exe" is. If it runs in PowerShell Studio but not as packaged exe, most likely you specify different options than what you have set in PowerShell Studio. That can be
- PowerShell version
- STA mode
- Elevation
- 32 or 64 bit mode

Additionally it can be a firewall exception you have for PowerShell Studio but not for your executable. Is your executable signed? Does it reside on a trusted location for .NET executables?
Did you turn off using a .config file for you packaged executable?
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 4 years and 9 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.
Locked