Testing shared datastores and network for a new VMware cluster using Powershell

15 Mar

Ok, you have built all the ESX hosts and create the clusters and everything looks ready to go; assuming that you ESX hosts are health and HA/DRS is setup. What would be a good simple test of this new cluster? Here is what I would test:

  • Ensure that all datastores are acccessible by each ESX host
  • Ensure that all public VLANs are are correct

To quickest test for this is to create an new VM, adding all the datastores to the VM and also all networks (assuming DHCP, but that is not really required) and build out either a new OS on it or boot it up to WINPE. What you want to do is to migrate this VM to each and every ESX host and ping the configured IP after that.

This does two things, if the VM migration is successful, it means that the datastores are configured correct on the ESX host and shared correctly. If after the migration and you can still ping all the configured address, it means that the network is correct configured on the ESX host.

After this fire up your VM and depending on your build environment it should come up with both NICs with an IP address. so here is a quick ps script that can use to test that VM can migrate across all your ESXi hosts (I am breaking it up for readabilty, everything should be on one line). Assuming 2 networks, you need to add the VM name, cluster name and ip1 and ip2 values and also add the ESX server names to the host file (except where the VM is).

Before this you need to logon to the VC using connect-VIServer command.

get-content .\hosts.txt | % { $h = $_ ; $h ; (get-vm <VM name> -Location “<clustername>”

| move-vm -Destination $_); test-connection <IP1> -quiet ;

test-connection <IP2> -quiet} | out-file .\output.txt -append

What it does:

  • Grabs a list of hosts from hosts.txt
  • for each host, it outputs the name
  • then it gets the VM object and migrates it to the ESX host
  • after that, it ping test the network connectivity
  • Finally, all these are output into a text file

In the output file, you can see something like this. As long as you can see the sequence of output below and true values, that ESX host is configured correctly. Not sure wh

VMTEST        PoweredOn  1        4096      
VMTEST        PoweredOn  1        4096

Leave a comment

Posted by on March 15, 2013 in Operations, powershell, vmware


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: