Why can't this Powershell command be executed within Jenkins?

删除回忆录丶 提交于 2019-12-13 05:44:37

问题


I have a simple powershell command to open a web application, and then input the quick-keys required to close it:

#Open Application in Browser
Add-Type –AssemblyName System.Windows.Forms
$ie = New-Object -com "InternetExplorer.Application"
$ie.Navigate("http://UrlPath")
$ie.visible = $true

#Quick key to exit application
sleep 15
[System.Windows.Forms.SendKeys]::SendWait("%{X}")

This code executes with no issue when I use powershell ISE outside Jenkins. But When I try to execute the code using the Powershell plugin, or using a batch file command within Jenkins to call the .ps1 file, it will always return the following errors.

Screenshot of errors returned by Jenkins

I'm using a virtual machine at work so at first I thought that was the issue. But I get the same results when using my home PC too. Any suggestions? I think the problem is permission based I'm not sure where to look to solve it.

The Powershell ISE I use outside jenkins is 32-bit, version 2.0

来源:https://stackoverflow.com/questions/39472969/why-cant-this-powershell-command-be-executed-within-jenkins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!