Searching for a VM
Posted on January 6, 2009 • 1 min read • 165 wordsOne of the problems that most people have with virtualizing vCenter is that they don’t know where the vCenter VM is when there are problems. There’s…
This is an archived article. It was originally published on
VMGuru
. This article may contain outdated information.
One of the problems that most people have with virtualizing vCenter is that they don’t know where the vCenter VM is when there are problems.
There’s a fairly easy way to counter this problem.
WIth a couple of PowerShell lines you can check all ESX hosts individual for the existance of the vCenter VM, in this case the S-VC.
One of the minor issues is that you have to logon to each server. With some more lines of code you can even circumvent that.
Here’s the code:
$searchservers = @('host1','host2','host3')
$SearchVM=’S-VC’
foreach ($vmhost in $searchservers) {
connect-viserver $vmhost > out-null if (
get-vm | where {$\_.Name -eq $SearchVM}
) {
write-host $SearchVM " found on host " $vmhost
}
}For this to work you need access to your ESX hosts from the network with the computer that’s running the script. You also need the VI Toolkit.