Jump to content
Sign in to follow this  
ur

Which Powershell command in the PowerCLI module for VMware ESX used to interact with UI apps?

Recommended Posts

Which Powershell command in the PowerCLI module for VMware ESX used to interact with UI apps?

 

When I launch any exe/any exeutable using powercli on guest VM using powercli command.

Invoke-VMScript, I am able to run them in the background but not in the foreground.

 

i.e., UI apps are not launching but showing the background as running in the task manager.

 

We need our UI Automation scripts to execute in the VM, but it is not working.

 

We are able to do in virtualbox and hyper-v but not in vmware esx using powercli.

 

Please suggest.

Share this post


Link to post
Share on other sites

As is clearly stated in the docs, Invoke-VMScript is meant to run background tasks, not foreground. If your script requires a GUI it will not work.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

Not in PowerCLI, no. Even PS Remoting will only open an interactive shell. Why run something remotely if you're going to be using a GUI? I'm trying to think of a scenario where you would do this; the whole point of remote execution is to get away from that. 


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

My autoit script contains gui testing of our windows desktop application.Where we check different features of our product from its UI.

This autoit exe, which we wrote for testing the UI, will be copied to esx test vm using copy commandlet of powercli.

And this script I am launching from invoke-vmscript.

Which is not opening the gui in foreground.

Any alternative in autoit to interact with foreground process when running in background?

 

 

Share this post


Link to post
Share on other sites

So you're going from powershell to AutoIt? 🤮

Have you tried just setting up a scheduled task to run the script?

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

The arguments changes to the script and also need the console output also. As I am running this powershell from jenkins.

 

Present I kept this schedule task as I you suggested.

Share this post


Link to post
Share on other sites
On 12/18/2019 at 4:41 AM, JLogan3o13 said:

So jenkins to powershell to AutoIt - I hope this is not a production pipeline you're trying to run like this.

Do you think it is a bad practice to have multiple environments involved?

Because, there is no UDF to control vms, so powershell is required here.

And, no UDF to have CI, so using Jenkins

Share this post


Link to post
Share on other sites

In most cases, I would say that mixing languages is a bad practice, yes. Since PowerShell (PowerCLI) can do everything you want with VMware, and also works nicely with jenkins (there are even a number of articles out there about making PS your orchestrator and bypassing jenkins altogether) I guess I don't understand the need for AutoIt. Again, you know your requirements better than I.


"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By DannyJ
      $sCommands1 = 'powershell.exe Get-ChildItem' $iPid = run($sCommands1   , @WorkingDir , @SW_SHOW , 0x2) $sOutput = ""  While 1     $sOutput &= StdoutRead($iPID)         If @error Then             ExitLoop         EndIf  WEnd ;~ msgbox(0, '' , $sOutput) ConsoleWrite("$sOutput") ConsoleWrite($sOutput) ConsoleWrite(@CRLF) $aOutput = stringsplit($sOutput ,@LF , 2) For $i=0 To  UBound($aOutput) - 1 Step 1     ConsoleWrite($aOutput[$i]) Next The script above reads the whole directory into a one dimensional array, but I need to work with the array, so I need to split the array into multiple dimensions.
      I have already read some forum answers here, and I have already tried these commands:
       
      Are there any way to use the $aOutput variable like in PowerShell:
      PowerShell:
      $a = Get-ChildItem $a.Mode I imagine this in AutoIt  $aOutput
      ConsoleWrite($aOutput[i].Mode) Or if I split this command into 2 dimension like:
      For $i To UBound($aOutput)-1 Step 1 ConsoleWrite($aOutput[$i][1]) ConsoleWrite($aOutput[$i][2]) Next  
    • By DannyJ
      If I try to run this script with   Get-ChildItem which means dir this script works perfectly, but If I try to run this command Get-RDUserSession, my script has the following error message:
      This command runs perfectly in PowerShell admin and I get back the values
      Get-RDUserSession -ConnectionBroker  broker.local | sort Username Or you can try this command as well
      Get-Command Get-RDUserSession If I run the above mentioned command this runs perfectly in PowerShell but not with AutoIt.
      Here is my script you can test the commands:
      #include<array.au3> $iPid = run('powershell Get-Command Get-RDUserSession'  , @WindowsDir , @SW_HIDE , 0x2) ;; This command not works in AutoIT you can test it in PowerShell but it won't work in Autoit ;$iPid = run('powershell Get-RDUserSession -ConnectionBroker  broker.local | sort Username'  , @WindowsDir , @SW_MAXIMIZE , 0x2) ; This command not works in AutoIT ;$iPid = run('powershell Get-ChildItem | sort Name'  , @WindowsDir , @SW_HIDE , 0x2) ; This runs perfectly $sOutput = ""  While 1     $sOutput &= StdoutRead($iPID)         If @error Then             ExitLoop         EndIf  WEnd ;~ msgbox(0, '' , $sOutput) $aOutput = stringsplit($sOutput , @LF , 2) _ArrayDisplay($aOutput)  
      That could be the solution of the problem if I could run, directly this PowerShell command window and Write to it and save it's values.
    • By ThePappas
      I am feeling really stupid. I cannot figure out what I am doing wrong.
      I followed the "Winzip" example, and I cannot get autoit to simply send an enter when the first window appears.  There are 2 windows like that, and neither one gets the enter.
      ShellExecute("VMware-EnhancedAuthenticationPlugin-6.7.0.exe") WinWaitActive("VMware Plug-in Service Installer.","instances will be closed") Send("{ENTER}") WinWaitActive("VMware Plug-in Service Installer.","run in succession") Send("{ENTER}") WinWaitActive("VMware Enhanced Authentication Plug-in 6.7.0","Welcome to the installation wizard") Send("!n") WinWaitActive("VMware Enhanced Authentication Plug-in 6.7.0","End-User License Agreement") Send("!a!n!n!i") WinWaitActive("VMware Enhanced Authentication Plug-in 6.7.0","Change") Send("!n") WinWaitActive("VMware Enhanced Authentication Plug-in 6.7.0","Install") Send("!i") WinWaitActive("VMware Enhanced Authentication Plug-in 6.7.0","Finish") Send("!f") WinWaitActive("VMware Plug-in Service","Welcome to the installation wizard") Send("!n") WinWaitActive("VMware Plug-in Service", "End-User License Agreement") Send("!a!n") WinWaitActive("VMware Plug-in Service", "Install the VMware Plug-in Service in") Send("!n") WinWaitActive("VMware Plug-in Service", "Install") Send("!i") WinWaitActive("VMware Plug-in Service","Finish") Send("f") I used the Window ID tool to verify that I am using the correct title, and those substrings appear in the dialog.
      I really did not want to have to post here, as this seems like a trivial effort.  But I am stuck.  I hate stuck.
      Thanks!
    • By DrLarch
      I'm trying to run this powershell command from Autoit and can't figure out how to pull it off:
      Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match "xbox" } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName } I've been trying to run it many different ways including:
      $sCMD = 'Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match "xbox" } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }' RunWait(@comspec & ' /c powershell.exe -nologo -executionpolicy bypass -noprofile -Command "&' & $sCMD & '"') The problem is that it seems I'm missing something in how to escape or double the quotes. I've tried doubling the quotes in many different ways, but the end result always produces a syntax error in powershell. I could just run powershell first, then paste and run the command, then close the powershell window, but that's clunky. I'm trying to do it either via parameter (as above) or in one line like this:
      RunWait(@comspec & ' /c powershell.exe -nologo -executionpolicy bypass -noprofile -Command "&Get-ProvisionedAppxPackage -Online | Where-Object { $_.PackageName -match "xbox" } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }"')  
    • By Jemboy
      I use Vmware Workstation to run servers, client and other devices. The reason I use Workstation instead of Esxi is because I find it easier to copy the VM files when the host machine crashes (just unplug *raid 1* disk and add it to the new host). 
      Because I do not want to reinstall everytime, I often copy an existing VM to test something  or just use the copy a base to install other apps.

      In the past I used to use VmConverter, but the latest version won't copy/rename my latest VMs anymore and the older VmConverters do not support the last VM-format.
      So  I decided to make my own "VmConverter" and called it "VMRenamer".
      I post this as is (it's working for me) and I encourage others to enhance the program as needed.
      Pre-requisites:
      You have to have VMWorkstation installed (I asume on a X64 Windows) You may NOT have snapshotted the VMware in ANY way, even after deleting the snapshot the VM is changed to much for my program to reliabily rename/change the VM files. I have used some snippets from other in my source and I wish to thank them for posting those on the forum/internet.
      Some remarks or obsolute functions have not been removed, because I wanted to post this for you out there instead of delaying the post longer.
      Enjoy!
       
      VmRenamer_1Q_2.zip
×
×
  • Create New...