Automation

 View Only
  • 1.  Power CLI equivalent to esxcfg-volume -M

    Posted Sep 30, 2011 01:06 PM

    Need to force-mount all available volumes to a few ESXi 4.1 servers and hoping to accomplish this with PowerCLI.

    Novice with PowerCLI but hoping there is something that can be used to automate force-mounting volumes.

    Thanks.



  • 2.  RE: Power CLI equivalent to esxcfg-volume -M

    Posted Sep 30, 2011 01:24 PM

    Have a look at the Powershell ResolveMultipleUnresolvedVmfsVolumes (equivalent of esxcfg-volume.pl) thread.

    As Vitali remarked, you should do this while connected (Connect-VIServer) to the ESX(i) server and not the vCenter server.

    And also have a look at the Enable Mount and resignature of  snap luns on vSphere thread



  • 3.  RE: Power CLI equivalent to esxcfg-volume -M

    Posted Sep 30, 2011 02:13 PM

    Thanks, LucD.

    The first one you linked to seems work well. Is there a way to have it call multiple ESXi servers and maybe prompt for credentials?

    If I exclude the username and password and leave the variable references it will prompt and still works which is fine.

    Here's what I've modified to get working;

    #$cluster =
    #$vcenter =
    $user =
    $password =
    Connect-VIServer myESXiServer
    Foreach($esxhost in (Get-VMHost -Location $cluster)){
        Connect-VIServer $esxhost -User $user -Password $password
        $hostView = get-vmhost -name $esxhost | get-view
        $dsView = get-view $hostView.ConfigManager.DatastoreSystem
        $unBound = $dsView.QueryUnresolvedVmfsVolumes()

        foreach ($ub in $UnBound) {
            $extPaths = @()
            $Extents = $ub.Extent;
            foreach ($ex in $Extents) {
            $extPaths = $extPaths + $ex.DevicePath
                                      }      
            $resolutionSpec = New-Object VMware.Vim.HostUnresolvedVmfsResolutionSpec[] (1)
            $resolutionSpec[0] = New-Object VMware.Vim.HostUnresolvedVmfsResolutionSpec
            $resolutionSpec[0].extentDevicePath = New-Object System.String[] (1)
            $resolutionSpec[0].extentDevicePath[0] = $extPaths
            $resolutionSpec[0].uuidResolution = "forceMount"

        $dsView = Get-View -Id 'HostStorageSystem-storageSystem'
        $dsView.ResolveMultipleUnresolvedVmfsVolumes($resolutionSpec)
        }
    }



  • 4.  RE: Power CLI equivalent to esxcfg-volume -M
    Best Answer

    Posted Sep 30, 2011 06:39 PM

    The first Connect-VIServer should be to your vCenter, otherwise the Get-VMHost will not return all the hosts in the cluster.

    And make sure that the VIServer mode is set to Multiple, that way you can have a connection to the server together with a connection to the ESXi server you're scanning.

    Use the Set-PowerCLIConfiguration cmdlet for setting the mode.



  • 5.  RE: Power CLI equivalent to esxcfg-volume -M

    Posted Sep 30, 2011 08:06 PM

    Thanks, Luc.

    I'll give it a go!

    Thanks again for the info, much appreciated.