Automation

 View Only
  • 1.  open vsphere console after After I get response from the server

    Posted Nov 01, 2015 02:10 PM

    I need to add the flowing options to my script:

    1. end ping session after getting a replay from my server and close the powershell console.

    2. open vsphere client after I get the replay from my server " Reply from 192.9.200.110: bytes=32 time<1ms TTL=64" and am massage that " please enter user name and password

    Regards,

    Michel vaillancourt



  • 2.  RE: open vsphere console after After I get response from the server

    Posted Nov 02, 2015 01:49 PM

    Can we see more of the script? It will help with taking a course of action. or providing you with some input.



  • 3.  RE: open vsphere console after After I get response from the server

    Posted Nov 03, 2015 02:17 AM

    For part 1, I would suggest the Test-Connection PowerShell command. With that, you can ping the server until it responds and then continue processing.

    After that, do you just want to launch the vSphere vCenter console? Or the actual VM Console itself? For the VM console, refer to the PowerCLI command Open-VMConsoleWindow.



  • 4.  RE: open vsphere console after After I get response from the server

    Posted Nov 11, 2015 02:27 PM

    After the server will respond i wont to lunch vsphere client with the user name and password details.

    I succeeded to lunch it with menially typing the commands in powershll but it didn't work when i try to run it as a script.

    Michel



  • 5.  RE: open vsphere console after After I get response from the server

    Posted Nov 13, 2015 01:08 PM

    Can you provide a copy of the script so we can take a look at what you have so far?



  • 6.  RE: open vsphere console after After I get response from the server

    Posted Nov 19, 2015 06:44 AM

    $Computer= "192.9.200.110"

    Connect-VIserver -server 192.9.200.110 -user root -Password Aa123456z

    $vm = Get-VM -Name Server2012R2

    if($vm.PowerState -eq 'poweredOn'){

    shutdown-VMGuest -VM $vm -Confirm:$false

    }

    while($vm.PowerState -eq 'poweredOn'){

    sleep 30

    $vm = Get-VM -Name Server2012R2

    }

    $vm = Get-VM -Name Windows8

    if($vm.PowerState -eq 'poweredOn'){

    shutdown-VMGuest -VM $vm -Confirm:$false

    }

    while($vm.PowerState -eq 'poweredOn'){

    sleep 30

    $vm = Get-VM -Name Windows8

    }

    Set-VMHost 192.9.200.110 -State 'Maintenance'

    Set-VMHostFirmware -VMHost 192.9.200.110 -Restore -SourcePath C:\Users\michelVA\Downloads\configBundle-192.9.200.110.tgz -HostUser root -HostPassword Aa123456z

    start-process powershell.exe -argument '-nologo -noprofile -executionpolicy bypass -command Test-connection 192.9.200.110 -count 50'

    Start-Sleep -Seconds 240

    Start-Process -FilePath C:"\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher"\VpxClient.exe



  • 7.  RE: open vsphere console after After I get response from the server

    Posted Nov 19, 2015 12:59 PM

    Ah, I think I have a better understanding of what you are trying to do.  Are you running vcenter?

    Also your last line the double quote needs to be at the end

    Start-Process -FilePath C:"\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe"

    I would add some logging to see where your script is stopping, it can be something simple with output to the shell

    example:

    $vm = Get-VM -Name Server2012R2

    write-host Shutting down $vm

    if($vm.PowerState -eq 'poweredOn'){

    shutdown-VMGuest -VM $vm -Confirm:$false

    }

    write-host pinging ESX

    start-process powershell.exe -argument '-nologo -noprofile -executionpolicy bypass -command Test-connection 192.9.200.110 -count 50'