I have promised you I would post this script, so here it is!
This Powershell script generates an overview of any items that are not available to every ESX server in a VMware cluster. These items might prevent your vm’s being vmotioned by DRS or restarted by HA. Pretty serious business, I’d say!
The items involved are:
1. datastores
2. LUNs (important when using Raw Device Mappings)
3. port groups
The output is a nicely formatted HTML page showing not only which items are misconfigured, but also where the are available and where they are absent.
And here’s the script:
Compare-Clusters (Rename to .ps1)
Enjoy!
Hugo
No related posts.


Alan Renouf
January 19th, 2009
That is one usefull script, nice one.
Sven Huisman
January 19th, 2009
Very nice! Bookmarked, downloaded and printed! Thanks.
Jay Rogers
January 22nd, 2009
I had problems running your script:
PS C:\iso\powershell> ./compare-clusters.ps1
There were one or more problems with the server certificate:
* A certification chain processed correctly, but terminated in a root certificate which isn’t trust
d by the trust provider.
* A required certificate is not within its validity period.
* The certificate’s CN name does not match the passed value.
Get-View : The argument cannot be null or empty.
At C:\iso\powershell\compare-clusters.ps1:23 char:36
+ $VMHostViews = $VMHosts | Get-View <<<< | Sort Name
Get-Datastore : The argument cannot be null or empty.
At C:\iso\powershell\compare-clusters.ps1:26 char:37
+ $Datastores = Get-Datastore -VMHost <<<< $VMHosts
Get-Datastore : The argument cannot be null or empty.
At C:\iso\powershell\compare-clusters.ps1:27 char:82
+ $DSdiffs = $VMHosts | ForEach {Compare-Object $Datastores (Get-Datastore -VMHost <<<< $_) -S
yncWindow 1000} | ForEach {$_.InputObject} | Sort Name | Select Name -Unique
Compare-Object : Cannot bind argument to parameter ‘ReferenceObject’ because it is null.
At C:\iso\powershell\compare-clusters.ps1:48 char:30
+ $LUNdiffs += Compare-Object <<<< $LUNs $HostLUNs -SyncWindow 1000 | ForEach {$_.InputObj
ect}
Get-VirtualPortGroup : The argument cannot be null or empty.
At C:\iso\powershell\compare-clusters.ps1:73 char:44
+ $PortGroups = Get-VirtualPortGroup -VMHost <<<< $VMHosts | ForEach {$_.Name} | Select -Uniqu
e
Get-VirtualPortGroup : The argument cannot be null or empty.
At C:\iso\powershell\compare-clusters.ps1:77 char:42
+ $HostPGs = Get-VirtualPortGroup -VMHost <<<< $VMHost | ForEach {$_.Name} | Select -Uniqu
e
Compare-Object : Cannot bind argument to parameter ‘ReferenceObject’ because it is null.
At C:\iso\powershell\compare-clusters.ps1:78 char:29
+ $PGdiffs += Compare-Object <<<< $PortGroups $HostPGs -SyncWindow 1000 | ForEach {$_.Inpu
tObject}
admin
January 22nd, 2009
The first error says that Get-View did not get any arguments. So there are two possible causes:
1) Get-View does not support input from pipeline. This is only the case for the beta release of the VI Toolkit. Make suer you use the v1.0.
2) The $VMHosts variable is empty, which would mean filling it somehow went wrong. Try dot-sourcing the script (start powershell interactively and run “. c:\iso\compare-clusters.ps1″ (without the quotes). Then take a look ate the variable $VMHosts if it contains anything.
Good luck,
Hugo
Daniel Hernandez
January 27th, 2009
Hey thanks for the great script. I also get a bunch errors similar to the one posted above. For the most part the script seems to run and produce a report its been very helpful in identifying invalid configurations.
As for possible debugging information that may help with the errors.
VC is 2.5 Update 3 on Win2k3 Server
Host are mostly 3.01
Toolkit Version is 1.0 build 113525
Am not sure if your open to feed back to continue to improve the script or if you released it to the community and for them to have at it.
If so here is my feedback.
Since its a cluster audit it would be nice not to see the local disk. Since I’ve seen most environments local label vary from host to host usually something along the lines with the hostname this usually helps to ensure that nobody puts a VM on the Local host.
Also I glance thru the script and I’m not sure are you checking for VLAN tags. Are you ? I’ve seen many issues because somebody fat fingered a VLAN tag. So a VM will move but not respond to any pings. Or even the VMotion port group wont move the VM because of the VLAN tag.
Thanks again
admin
January 27th, 2009
Hi Daniel, thank you for taking the time to post your comment. I read every comment on my site and try to improve my scripts or help out in other ways. Keep watching my site and you might see an improved version of the script some time soon. Thanks again for your comments!
Hugo
Roderick
January 28th, 2009
How do I get rid of this annoying output when I run the powershell scripts?
There were one or more problems with the server certificate:
* A certification chain processed correctly, but terminated in a root certificat
e which isn’t trusted by the trust provider.
admin
January 28th, 2009
You can import the certificate to get rid of the first message, but the second one will remain as your server will most likely not be called ‘vmware’. Might work to create a dns alias for it, but that’s not very nice. Maybe you can find out a way to generate a new certificate with the proper server name in it. If anybody finds a way before I do, let me know.
Hugo
Larry
February 3rd, 2009
Thanks for lots of great scripts. Looking for VCB ones but liked what I found anyway. My script works some time but other times the snapshot times out. Wanted your clear connection script to see if that was my issue, wasn’t. Your list disks script will help also.
Roderick
February 5th, 2009
This is probably an open door, but how do I import a certificate?
Paul
February 12th, 2009
Hi Hugo,
I was trying to do exactly as Daniel requested and managed to fudge something together. Would appreciate it if you would take the time to have a look and see how it could be improved as i think the method I came up with to compare VLANS works but is a little convoluted.
let me know if you have the time or inclination to take a look and i’ll post the script.
Hugo
February 12th, 2009
@Paul
Hi Paul,
Sure I’d like to check what you did. Drop me an email at: contact at peetersonline nl
Hugo
Duncan
February 16th, 2009
Just ran this script and it works fine but:
- you might want to filter the local luns (vmhba0:0:0) cause they usually have a different name on every single host in a cluster
- the script throws an error when a cluster doesn’t contain hosts
Nick
May 11th, 2009
I was wondering if Paul had a workable solution or addition for auditing the port group VLANs. I love the script above but really need to audit the por group VLANs as well.
Alan
June 24th, 2009
agree with Duncan, GREAT script but is there an easy way to filter out local luns?
level67
October 9th, 2009
Hi Guys,
Got the same issue, its reporting my local drives as datastores and reporting a mismatch on the clusters.
Any chance of looking into this? Great work otherwise… love it!
Andy
August 27th, 2010
Hi Hugo,
Great script, I was a little confused on one of my outputs because there were several vmhba devices denoted across the ESXhosts. It is simple to figure out the ones that have 1 vmhba denoted and the rest saying true or false but having more than one has confused me. Can you help to decipher this?
LunUuid ESX001.xxx ESX002.xxx ESX003.xxx ESX005.xxx ESX011.xxx ESX020.xxx
0200010000600508b400106b3400009000020c0000485356323130 vmhba0:4:1 vmhba0:2:1 vmhba0:4:1 vmhba0:1:1 False vmhba0:2:1
0200020000600508b400106b3400009000020c0000485356323130 False False False False vmhba0:4:2 False
0200020000600508b400106b340000900002110000485356323130 vmhba0:4:2 vmhba0:2:2 vmhba0:4:2 vmhba0:1:2 False vmhba0:2:2
0200030000600508b400106b340000900002110000485356323130 False False False False vmhba0:4:3 False
Thanks!
Also, it would take longer but could you include a host rescan before the script starts executing so that all of the data can be current?