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.
4 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
Comments
Since Jenkins is running as service, you can open services.msc and right click on Jenkins. Then click Properties, go to Logon tab, check mark This account and enter username and password which has admin privileges. Stop and Start Jenkins service.
From now on when you will run powershell commands in Jenkins, they will be run as administrator.