Ever wanted to trigger a recsan of storage for all hosts in a given cluster? There may be a reason why you would want to do this via a script rather than a gui and if so, this is it.
I have written it as a function.
The code will connect to a VC, identify the cluster (you give it the cluster name as a parameter), get a list of hosts, and then for each host, trigger a rescan.
Unfortunately, it runs serially, rather than triggering a parallel run. At this stage it doesn’t really matter to me, but at some point, I will write a version that does the rescan’s in parallel.
Function Rescan-ClusterHBA { param ([string]$vmClustername, $viserver) Connect-VIServer $viserver $vmClusterPointer = get-cluster $vmClusterName $vmcluster = $vmClusterPointer | Get-View $vmhosts = $vmcluster | select -Expand host foreach ($vmhost in $vmhosts) { Get-VMHost -Id $vmhost Get-VMHostStorage -vmhost (Get-VMHost -Id $vmhost) -RescanAllHba } }