Jan
06
2009

Searching for a VM

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.

  • Share/Bookmark

Related posts:

  1. Creating portgroups with PowerShell
  2. More PowerShell stuff
  3. Browsing through your VC database like a drive
  4. Upgrading VMware ESX 3.5 to ESX 4.0 (vSphere)
  5. Code pages added
Written by Anne Jan Elsinga in: PowerShell, vCenter/VirtualCenter | Tags: , ,
In real live MeAgain is Anne Jan Elsinga. He's a Technical Consultant for Centric Managed ICT Services in the Netherlands. He spends his working hours with a lot of virtualization stuff, from feasibility to implementation for server virtualization/consolidation and desktop virtualization. In the night time he dances latin, ballroom and salsa and he recently discovered the pleasure of diving.
blog comments powered by Disqus

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes