Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 192300

Re: mount the replicated volumes

$
0
0

Here's the updated script:

 

# 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

    $UnresVols | %{

      $Extent = $_.Extent

      $DevicePath = $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


Viewing all articles
Browse latest Browse all 192300

Trending Articles