I am looking at recoding some of the esxcfg-volume.pl in Powershell, can anyone assist with the final part of this section where I am unfortunately receiving
Exception calling "ResolveMultipleUnresolvedVmfsVolumes" with "1" argument(s): "Cannot change the host configuration." At line:1 char:47 + $vmHostSS.ResolveMultipleUnresolvedVmfsVolumes <<<< ($HUVRSarray) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException
This is using : vSphere 4.1, PowerCLI 4.1, Powershell 2.0
Connect-viserver $viServer $vmHost = Get-VMHost $vmHostName $vmHostView = get-View $vmHost.Id $vmhostSS = get-view $vmHostView.ConfigManager.StorageSystem $vmHostDS = get-view $vmHostView.ConfigManager.DatastoreSystem $vmHostSS.RefreshStorageSystem() $vmHostUVs = $vmHostDS.QueryUnresolvedVMFSVolumes() if ($vmHostUVS) { $newUVs = @() $ID = [int]-1 $maxID = [int]-1 foreach ($vmHostUV in $VMHostUVs) { $newUV = "" | Select-Object ID,VMFSUUID,VMFSLabel,Mountable,Resignable,Extent $ID += 1 $maxID += 1 $newUV.ID = $ID $newUV.VMFSUUID = $vmHostUV.VMFSUUID $newUV.VMFSLabel = $vmHostUV.VMFSLabel $tempError = "" if (!($vmHostUV.ResolveStatus.Resolvable)) { if ($vmHostUV.ResolveStatus.IncompleteExtents) { $tempError = "(Some Extents Missing)" } elseIf (if ($vmHostUV.ResolveStatus.MultipleCopies)) { $tempError = "(Duplicate Extents Found)" } elseif (if ($vmHostUV.Extent.Count -gt 1)) { $tempError = "(Some Extents Missing)" } # End If $newUV.Mountable = "No" $newUV.Resignable = "No" } ElseIf (1 -eq 2) { $newUV.Mountable = "No (The Original volume is still online)" $newUV.Resignable = "Yes" } Else { $newUV.Mountable = "Yes" $newUV.Resignable = "Yes" } # End If $newUV.Extent = $vmHostUV.Extent $newUVs += $newUV } # Next Write-Output $newUVs | Select-Object ID,VMFSUUID,VMFSLabel,Mountable,Resignable | Format-Table -AutoSize | Out-Default } # End If do { $UVNum = Read-Host "Select Volume to Add" } while ([int]$UVNum -lt [int]0 -or [int]$UVNum -gt [int]$maxID) $HUVRS = New-Object vmware.vim.HostUnresolvedVmfsResolutionSpec $newPaths = New-Object System.String[] (1) $newPaths[0] = $newUVs[$UVNum].extent[0].DevicePath $newPaths[0] $HUVRS.ExtentDevicePath = $newPaths $HUVRS.UuidResolution = "forceMount" $HUVRSArray = New-Object vmware.vim.HostUnresolvedVmfsResolutionSpec[] (1) $HUVRSArray[0] = $HUVRS $Result = $vmHostSS.ResolveMultipleUnresolvedVmfsVolumes($HUVRSarray)
Thanks
Looks like you're hitting the same bug as reported in
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
From what I understood one of the references in that posting suggests that the volume may already be seen, but this is not the case with us. Also using the esxcfg-volume.pl script, this works perfectly. Is there a possible issue with my definition of the HostUnresolvedVmfsResolutionSpec object?
Hi there,
can you try the same script with connection to ESX instead of VC connection. See this kb article:
Vitali
PowerCLI team
Has anybody been able to get ResolveMultipleUnresolvedVmfsVolumes working using powercli with the newer versions of PowerCLI and vSphere?