Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run powershell commands in administrative mode using jenkins?

I have a .ps1 file which needs to be run in administrative mode for it to work. But unfortunately I couldn't find a way to do that using Jenkins. Currently I am running this powershell command in execute batch command on Jenkins with all possible options. But it's not working.

like image 724
Krishna Prasad S Avatar asked Oct 22 '25 03:10

Krishna Prasad S


2 Answers

Easy hack to solve this was indeed adding a .bat file that was run from the Jenkins(Execute windows batch command). The bat file had following command which did run the powershell script with elevated(admin) rights

powershell -ExecutionPolicy Unrestricted -File your_script.ps1 --settings_skipverification=true
like image 112
Krishna Prasad S Avatar answered Oct 23 '25 16:10

Krishna Prasad S


Execute it with Invoke-Command via Jenkins.

Invoke-command -FilePath Script.ps1
like image 41
Prasoon Karunan V Avatar answered Oct 23 '25 18:10

Prasoon Karunan V