问题
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