Hi Luc D,
Can you please review the modified script, I guess the only thing missing is $UnresVol = $UnresVols["Array Index"]?
# load the VMware module
$VimAutoCore = "VMware.VimAutomation.Core"
if ( (Get-PSSnapin -Name $VimAutoCore -ErrorAction SilentlyContinue) -eq $null ) {
Write-Host "loading $VimAutoCore powershell module"
Add-PsSnapin $VimAutoCore
}
#connect to the vCenter Server
$vcenter = Read-Host "Please enter the vCenter Hostname or IP Address?"
#prompt for ClusterName
$cluster = Read-Host "Please enter the Cluster name"
#this will prompt the user to enter the user name and password to connect to the vCenter
Write-Host "Connecting to vCenter Server" -ForegroundColor Yellow
Connect-VIServer -Server $vcenter -ErrorAction Stop -Protocol https
Get-Cluster $cluster | Get-VMHost | Get-VMHostStorage -RescanAllHba
ForEach($esx in $cluster){
# Do step 2
$VMHost = Get-VMHost
$HstSys = Get-View $esx.id
$HstDsSys = Get-View $HstSys.ConfigManager.DatastoreSystem
$UnresVols = $HstDsSys.QueryUnresolvedVmfsVolumes()
# Do step 3
$HstSSys = Get-view $esx.StorageInfo
$UnresVol = $UnresVols[Array Index]
$Extent = $UnresVol.Extent
$DevicePath = $UnresVol.Extent.DevicePath
$ResSpec = New-Object Vmware.Vim.HostUnresolvedVmfsResolutionSpec[](1)
$ResSpec[0].ExtentDevicePath = $DevicePath
$ResSpec[0].UuidResolution = “forceMount”
$HstSSys.ResolveMultipleUnresolvedVmfsVolumes($ResSpec)
# Do step 4
$esx | Get-VMHostStorage -RescanVmfs
}
Disconnect-VIServer $vcenter -Confirm:$false