This sounds like a simple question, but I haven't been able to work it out after looking online. I basically want to execute a PowerShell script (e.g. script.ps1) in Jenkins and report success/failure.
Try 1: Run following as "Execute Windows Batch Command"
powershell -File c:\scripts\script.ps1
This starts up as expected, but it quits after a few seconds.
Try 2: Run following as "Execute Windows Batch Command"
powershell -NoExit -File c:\scripts\script.ps1
This runs the whole script successfully, but it never stops. I had to manually abort the script.
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.
Jenkins PowerShell PluginIntegrates with PowerShell by allowing you to directly write PowerShell scripts into the text box in Jenkins. Other than that, this plugin works pretty much like the standard shell script support.
PowerShell can be used to automate tasks such as user management, CI/CD, managing cloud resources and much more. You'll learn to run commands, how to learn more about PowerShell and additionally to create and run script files.
Well, there is a PowerShell plugin, which is wrapping the shell anyway. I use this on my server, executing scripts in standard notation:
powershell -File test001.ps1
It works without any quirks.
I found the problem came down to PowerShell managing the execution policy separately for 32-bit and 64-bit versions. Checkout http://www.gregorystrike.com/2011/01/27/how-to-tell-if-powershell-is-32-bit-or-64-bit/ to try launching both. Run Get-ExecutionPolicy
in both and you will see they are different.
At least with version 1.4, it appears the plugin ends up using the 32-bit process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With