Hi Team,
I am trying to mount the replicated LUN(s) at a DR Site via PowerCLI Script. but getting some errors:
Can someone please help?
Here is the script:
#prompt for ClusterName
$cluster = Read-Host "Please enter the Cluster name"
Get-Cluster $cluster | Get-VMHost | Get-VMHostStorage -RescanAllHba
ForEach($esx in $cluster){
# Check for unresolved UUID
$VMHost = Get-VMHost
$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
#$esx | Get-VMHostStorage -RescanVmfs
Get-VMHostStorage -VMHost $VMHost -RescanVmfs
}
Here is the output:
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is
null or empty. Supply an argument that is not null or empty and then try the
command again.
At C:\Citi_Scripts\MountLUNs.ps1:48 char:26
+ $HstSys = Get-View $esx.id
+ ~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is
null or empty. Supply an argument that is not null or empty and then try the
command again.
At C:\Citi_Scripts\MountLUNs.ps1:49 char:28
+ $HstDsSys = Get-View $HstSys.ConfigManager.DatastoreSystem
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView
You cannot call a method on a null-valued expression.
At C:\Citi_Scripts\MountLUNs.ps1:50 char:22
+ $UnresVols = @($HstDsSys.QueryUnresolvedVmfsVolumes())
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Get-View : Cannot validate argument on parameter 'VIObject'. The argument is
null or empty. Supply an argument that is not null or empty and then try the
command again.
At C:\Citi_Scripts\MountLUNs.ps1:53 char:27
+ $HstSSys = Get-view $esx.StorageInfo
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingVal
idationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,VMware.VimAutom
ation.ViCore.Cmdlets.Commands.DotNetInterop.GetVIView