PowerCLI: Find vCenter without vCenter
If you don’t know already PowerCLI now has two modes single and multiple. It stands for exactly what you think it does. In single mode when you execute a command PowerCLI runs that command against the server you’re connected too. Multiple mode allows you to specify multiple vCenter/ESX/vSphere host, and when you execute a command it runs that command against every server you’ve specified! This had to be one painful feature to get right, but the PowerCLI team nailed it.
I’ll admit when I first played with it I thought I wouldn’t never need/use multiple mode. That is until our vCenter server was inadvertently shutdown instead of rebooted. Normally this would lead to one of two out comes.
A.) forcefully register vCenter on the first host I hit and power it up.
B.) A twenty minute search for the host that has vCenter.Well today I didn’t feel like doing either… On a whim I tried this new-fangled multiple connection thing… IT WORKED!
# Set PowerCLI to multiple Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false # Connect to every vSphere host in the cluster that contains vCenter Connect-VIServer -User root -Password password -Server esx1,esx2,esx3,esx4,esx5,esx6,esx7,esx8 # Start vCenter Get-VM vCenter01 | Start-VMI’ve since wrapped all this up in a batch file and added it to our playbook for a lights out recovery of virtual center!
~Glenn