1

Is there any way to disable the need to run in an elevated context for a powershell script? Anything goes.

I am setting up a test environment and during some of the tests I must reconfigure parts of the OS (notably: an IIS instance) - and windows keeps asking to run the script from an elevated process.

Those are test machines. As such, "anything goes", including turning off UAC - which I did, but PowerShell still asks.

3
  • Did you reboot after turning off UAC? Feb 4, 2017 at 22:09
  • 2
    If anything goes, why don't you use the Administrator account to log on, or just open one elevated PowerShell session and start all your tests from there. Feb 6, 2017 at 1:13
  • If you are asking if you can start a non-elevated PowerShell window and then run programs that require elevation without provoking the UAC prompt, then the answer is no. I recommend doing what @PeterHahndorf suggested - just open a PowerShell window that's already elevated (answer UAC prompt just once) and do what you need to do there. Feb 14, 2017 at 23:49

2 Answers 2

1

You can try setup enviropment variable __COMPAT_LAYER to value RUNASINVOKER before script runs - it may prevent elevation request if it realy not needed. This elevation request suppression method described in this blog post, and it's work for me in some cases.

1

Have you tried disabling the "User Account Control: Turn on Admin Approval Mode" policy setting?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .