Page 1 of 1

Clarification on RunAs and SetExecution

Posted: Wed Jun 12, 2019 11:35 am
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.

Re: Clarification on RunAs and SetExecution

Posted: Wed Jun 12, 2019 12:12 pm
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.

Re: Clarification on RunAs and SetExecution

Posted: Wed Jun 12, 2019 11:25 pm
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?