Here's the updated script:
#prompt for ClusterName
$clustername = Read-Host "Please enter the Cluster name"
$cluster = Get-Cluster -name $clustername
Get-Cluster $cluster | Get-VMHost | Get-VMHostStorage -RescanAllHba
$hostsincluster = Get-VMHost -Location $cluster
ForEach($esx in $hostsincluster){
# Check for unresolved UUID
$VMHost = $esx
$HstSys = Get-View $esx.id
$HstDsSys = Get-View $HstSys.ConfigManager.DatastoreSystem
$UnresVols = @($HstDsSys.QueryUnresolvedVmfsVolumes())
# Resolve UUID for each on each ESXi host in the cluster
$HstSSys = Get-view $esx.StorageInfo
$UnresVols | %{
$Extent = $_.Extent
$DevicePath = $Extent.DevicePath
$ResSpec = New-Object Vmware.Vim.HostUnresolvedVmfsResolutionSpec[](1)
$ResSpec[0].ExtentDevicePath = $DevicePath
$ResSpec[0].UuidResolution = “forceMount”
$HstSSys.ResolveMultipleUnresolvedVmfsVolumes($ResSpec)
}
# Rescan for VMFS volumes
$VMHost | Get-VMHostStorage -RescanVmfs
}