I'm trying to create automated scripts that rely on knowing when my vCenter Server is actually accessible via powercli.
I've installed vCenter on a windows VM not the vCSA.
Using Alan Renouf's example I was able to check the status of services as the VM starts, but they didn't seem to relate to when I could connect to vCenter either with PowerCLI or through the web client.
Even after the VM is started and the VMware services are all in a "Running" state, there's a few minutes before you can actually get access.
Any ideas how to find the moment that vCenter becomes available through PowerCLI / Powershell query or another method?
Versions:
ESXi 6.5
vCenter Server 6.5 (Win2012 Server)
PowerCLI 6.3 R1
I was looking for the same, but then for a VCSA.
Haven'y found anything conclusive I'm afraid.
In the end I reverted to a Try-Catch in a timed loop, where I do a Connect-VIServer till it succeeds.
Open for better ideas :smileygrin:
Update: at one point I waited for the 'Web Client service' to run (on a VCSA), but that wasn't conclusive to be able to do a Connect-ViService.
I used something like this
# Wait for start of VCSA services
# Use the Web Client service to check
$sshUser = $vcsaCred.GetNetworkCredential().username
$sshPswd = $vcsaCred.GetNetworkCredential().password
$plinkoptions = "-ssh -l $($sshUser) -pw '$($sshPswd)'"
$plinkHost = $vm.networkConnections[0].ipConfig.fqdn
$plinkCmd = 'service vsphere-client status'
$msg = ""
while($msg -notmatch 'VMware vSphere Web Client is running:'){
sleep 10
$msg = Invoke-Expression -Command "echo Y | $($plinkDir)\Plink.exe $($plinkOptions) $($plinkHost) $($plinkCmd)"
}
Still looking for a 100% working test, so I can finally finish my automatic lab startup script
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I appreciate the feedback. I'll keep trying and maybe do something similar in the meantime.
Thanks!
