Every now and then customers ask if it is possible to check if disk controllers are on the VSAN HCL (Or VMware Compatibility Guide (VCG) as it is actually called these days) for a given set of hosts through PowerCLI. Alan Renouf figured he would knock something out, thanks Alan for sharing! (Next up would be validate drivers and firmware of all components, thanks!) What this script does is the following, note that you need internet access for this to work:
- Connect to vCenter
- Download latest VSAN HCL details (json file)
- Compare controllers of each host against the VSAN HCL
- Report the state of your infra
Here is the script, it can also be found in the VMware Developer Center repository by the way.
Connect-VIServer myvcenter -user Administrator -password MyPass23 Function Get-CompatibleVSANController { if (-Not $vSANHCL) { $vSANHCL = Invoke-WebRequest -Uri http://partnerweb.vmware.com/service/vsan/all.json | ConvertFrom-Json } $vSANHCL.data.controller } $HBAs = get-vmhost | Get-VMHostPciDevice | where { $_.DeviceClass -eq "MassStorageController" } Foreach ($HBA in $HBAs) { $HBAFound = $false Write-Host "Looking for $($hba.name) from host $($HBA.VMhost)" Foreach ($entry in Get-CompatibleVSANController) { $vid = [String]::Format("{0:x}", $HBA.VendorId) $did = [String]::Format("{0:x}", $HBA.DeviceId) $svid = [String]::Format("{0:x}", $HBA.SubVendorId) $ssid = [String]::Format("{0:x}", $HBA.SubDeviceId) If (($vid -eq $entry.vid) -and ($did -eq $entry.did) -and ($svid -eq $entry.svid) -and ($ssid -eq $entry.ssid) ) { Write-Host " HBA in $($HBA.VMHost) is $($HBA.Name) which can be found in the HCL as $($Entry.vendor) - $($Entry.Model) at the following URL: `n $($entry.vcglink)" -ForegroundColor Green $HBAFound = $true } } If (-Not $HBAFound){ Write-Host " $($HBA.Name) in $($HBA.VMHost) is not found!" -ForegroundColor Red } }
If you run it the output will look like this:
Steffen Oezcan says
Hi Duncan, I am just at a customer site with PSO and they would LOVE to use that – but their vCenter is and will stay disconnected from the Internet. We are building a process to automatically download and bring the updated json-File for the HCL to vCenter via the offline import. Any chance this script of Alan (thanks!) could be adjusted to work also against the vCenters imported json-offline file? Would be much appreciated.
BR
Steffen
Alan Renouf says
Stefan,
Sure, just change Line 6 to the following:
$vSANHCL = Get-Content -Path C:\temp\all.json | ConvertFrom-Json
Alex says
Great post Alan – this is JUST what I was looking for! Do you think you could enlarge the output example screenshot example?
Duncan Epping says
here is the full size output:
https://c2.staticflickr.com/2/1660/25103202661_638b139518_o.png
my blog theme doesn’t allow me to post pics this big, but this should work.
caleb says
Great script. Like the others. I’ll be using it heavily.
Have you found any way to trigger using Powercli the other various health tests for vSAN that are available from the web client? I would have thought that there would have been cdmlets included in Powercli 6 R3 vmware.vimautomation.storage module. But alas I came up short. any help is appreciated.