VMware Cloud Community
michelvaillanco
Enthusiast
Enthusiast

open vsphere console after After I get response from the server

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

0 Kudos
6 Replies
jpsider
Expert
Expert

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

0 Kudos
aaron416
Enthusiast
Enthusiast

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.

0 Kudos
michelvaillanco
Enthusiast
Enthusiast

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

0 Kudos
jpsider
Expert
Expert

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

0 Kudos
michelvaillanco
Enthusiast
Enthusiast

$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

0 Kudos
jpsider
Expert
Expert

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'

0 Kudos