Compare ESX configurations with Powershell

One of the challenges in managing a large VMware Infrastructure is keeping all ESX Servers within a cluster equal. This is essential for having vmotion capabilities and therefore essential for a solid HA configuration. I have showed you earlier how to add the LUN Count for each ESX Server to your VI Client. This allows you to spot differences quickly. But finding exactly which datastores are missing on which ESX Server can be a bigger challenge.

Here are some small functions that can help you determine where the major differences are.

Comparing datastores:

function Compare-VMHostDatastores
{
param([string]$host1,[string]$host2)
$a = Get-VMHost $host1 | Get-Datastore | %{$_.Name}
$b = Get-VMHost $host2 | Get-Datastore | %{$_.Name}
Compare-Object $a $b
}

Compare-VMHostDatastores esxServer1 esxServer2

InputObject                         SideIndicator
———–                                ————-
esxServer1_Local             <=
esxServer2_Local             =>
DATASTORE_TEST1         =>

And comparing Port Groups:

function Compare-VMHostPortgroups
{
param([string]$host1,[string]$host2)
$a = Get-VirtualPortGroup (Get-VMHost $host1) | %{$_.Name}
$b = Get-VirtualPortGroup (Get-VMHost $host2) | %{$_.Name}
Compare-Object $a $b
}

Compare-VMHostPortgroups esxServer1 esxServer2

InputObject                SideIndicator
———–                      ————-
PortGroup_TEST     <=
Internal                       <=

Maybe you prefer to go the other way around and check to which ESX servers a specific datastore is attached?

function Get-DatastoreHosts
{
param([string]$datastore)
Get-VMHost -Datastore (Get-Datastore $datastore) | Sort Name | %{$_.Name}
}

PS D:Scripts> Get-DatastoreHosts DATASTORE_TEST1

esxServer2
esxServer3

Thank Microsoft for Powershell and the Compare-Object cmdlet!

Hugo

//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

(adsbygoogle = window.adsbygoogle || []).push({});

Team, stars included. Moreover, RPE abnormality is a cheap football jerseys common occurrence Wholesale China Jerseys associated with AMD7,8, and RPE pigment Replica Oakleys relocation has been reported in mouse models of inherited retinopathies28 and human patients with retinitis pigmentosa29 and AMD30. Athletic shoes and clothing are not an infinite market and every dollar spent on a competitor is a dollar not being spent on Nike. For these guests you could have soft drinks and lots Cheap Football Jerseys replica oakleys of water. Others may be files that can only be used with programs like Photoshop like PNG files. ”I had never heard of the game until April. Send an email or letter to NBA coaches, and ask them to give you some insights about the game and some of their coaching philosophies and strategies. They were no threat to us. And instead of defaulting to free clipart, why not try a few high quality Photoshop brushes? These will give you a professional quality invitation without the cheesiness factor that you get http://www.cheapoakley2012.com from clipart that hasn’t been updated since 1995. Let’s have some fun!Hi people! I made a prototype and I also put up a video on youtube featuring the device, it a bit differnt to this one but the concept is still the same! I know that my energy is higher using this comparing to not, Iv meassured my performance for different excercises!Is there some reason why you just can plunge your hand into ice water?. TofuXpress When I finally learned how to prepare tofu correctly, I realized so much of it had to do with the water content. The yellowish tint of a diamond is caused by nitrogen impurities, which means that last week’s find is of extremely high quality.. Moving on to the next page, the identifiable cost synergies. Was my first football game, ever. Joes on Cable Television. The losses were a little bit http://www.cheapnfljerseyssu.com more than we expected in the quarter. Sure, Gilead has storm clouds over it, but it’s all about the money.. It’s also why we’re going to accelerate investment in the business in the back half of the year.. 1 overall pick, then proceeded to get their hopeful franchise quarterback a few playmakers to build around. Back then, the following week we dipped only 9.4 cents lower before rallying 25.4 cents off the bottom, and closed up 6.7 cents for the week. Overall, we are optimistic about our prospects in the communications space.. New England Seattle coach Pete Carroll was 27 21 (1 2 in playoffs) in three seasons as Patriots coach from 1997 1999. To get a snapshot of what their mindset was like heading in, it’s helpful to know that the assignment was considered an extremely dangerous one by the Soviet Army, and that the Soviet Army’s slogan at the time was “die for Russia.”.

12 thoughts on “Compare ESX configurations with Powershell”

  1. Pingback: Compare specific ESX configuration items « H9Newser’s Blog
  2. Hi Hugo,

    any idea why when i run this script i only get back my local datastores?

    param([string]$host1,[string]$host2)
    $a = Get-VMHost $host1 | Get-Datastore | %{$_.Name}
    $b = Get-VMHost $host2 | Get-Datastore | %{$_.Name}
    Compare-Object $a $b

    but if i run
    $a = Get-VMHost $host1 | Get-Datastore | %{$_.Name}
    $a

    i get all my datastores?

    cheers

    1. Hi Paul,
      Be glad. The local datastores are the only difference between the two hosts. Add the -IncludeEqual switch to the Compare-Object line to show all datastores.
      Hugo

  3. Hi Hugo,

    I was expecting to get back all my datastores with the ones being equal having a == sign in the SideIndicator. But having read the help on compare-objectshow them.

    thanks for that!

    Paul

  4. Hugo,

    I assume you have Powershell and the VI Toolkit installed. Start the VI Toolkit console (which is essentially Powershell with the VI Toolkit snapin loaded). Connect to Virtual Center using “Connect-VIServer MYVCSERVER”.

    Manually:
    Copy and paste the functions into the window and press enter a few times. Then you can use the functions by typing the name and supplying two host names or a datastore name (see the second quotes for examples). When you close the window, the functions are forgotten.

    Profile:
    Add the functions to your profile in order to have them available every time you open the Powershell / VI Toolkit window. Read this for more info: http://www.peetersonline.nl/index.php/powershell/build-your-own-powershell-universe/

    Hugo

Leave a Reply