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.

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.

Posts: 14618
Joined: Tue May 22, 2007 9:57 am
Answers: 3
Has voted: 1 time
Been upvoted: 3 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: 7525
Joined: Tue May 29, 2007 4:43 pm
Answers: 1
Been upvoted: 2 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.