Search code examples
powershelljenkinsjenkins-cli

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.


Solution

  • 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