Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid UAC prompt while running powershell script

I am running powershell script through jenkins. It has one cmdlets which require elevated permission. so i am writing those cmdlet as below

start-process powershell.exe -verb runas -argumentlist "net localgroups administrators domain\user /add" 

But this prompts a UAC where i have to manual click yes. then its moves further. I want to elevate the cmdlet without giving UAC prompt and continue to go ahead....

The account used to run the script has admin permission on that machine.

like image 893
Amit Avatar asked Sep 18 '26 13:09

Amit


1 Answers

Besides disabling UAC - which obviously should be the last resort - you may achieve your goal with creating a 'scheduled' task which is set up to run elevated and trigger that task from Jenkins.
The difficulty here will be probably about how to pass information to and retrieve information from the task - maybe you can achieve that via some files of well-known paths.
See here for how to set up such a task and here for how to trigger it.

As I do not have any Jenkins installation right now I could not test it though - sry.

like image 147
DAXaholic Avatar answered Sep 20 '26 02:09

DAXaholic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!