Hi,
Please help me to get the host name from below rescan command.
Command : Get-Cluster MyCluster | Get-VMHost | Get-VMHostStorage -RescanAllHba
Output :
SoftwareIScsiEnabled
--------------------
False
False
False
False
The RescanHBA method doesn't return anything, so you can't include the outcome of the scan just like that.
To display the host and HBA you can do
$storSys = Get-View -Id $hba.VMHost.ExtensionData.ConfigManager.StorageSystem
$storSys.RescanHba($hba.Device)
$hba | Select @{N='VMHost';E={$_.VMHost.Name}},Name
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Does this return the host?
Select @{N='VMHost';E={$_.VMHost.Name}},SoftwareScsiEnabled
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
How can I rescan only fnic or fibre and get only its output ?
Not with a cmdlet afaik, but you can use the RescanHba method, which allows the scan of a specific HBA.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
I am getting the below error
Get-Cluster Compute | Get-VMHost | Get-VMHostStorage -rescanHba vmhba1
Get-VMHostStorage : A parameter cannot be found that matches parameter name 'rescanHba'.
At line:1 char:58
+ Get-Cluster Compute | Get-VMHost | Get-VMHostStorage -rescanHba vmhba1
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-VMHostStorage], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.GetVMHostStorage
That is not a cmdlet nor a cmdlet parameter, but an API method.
Something like this
$storSys = Get-View -Id $_.VMHost.ExtensionData.ConfigManager.StorageSystem
$storSys.RescanHba($_.Device)
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD,
Thanks a lot, it worked but I am unable to get the hostname and HBA device name in the output.
The script runs successfully but no hostname and HBA device name in the output.
I tried as below
Get-VMHost | Get-VMHostHba -Type FibreChannel | %{
$storSys = Get-View -Id $_.VMHost.ExtensionData.ConfigManager.StorageSystem
$storSys.RescanHba($_.Device)
} | Select @{N='VMHost';E={$_.VMHost.Name}}
The RescanHBA method doesn't return anything, so you can't include the outcome of the scan just like that.
To display the host and HBA you can do
$storSys = Get-View -Id $hba.VMHost.ExtensionData.ConfigManager.StorageSystem
$storSys.RescanHba($hba.Device)
$hba | Select @{N='VMHost';E={$_.VMHost.Name}},Name
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked .
Thank you very much for your help.
One last question, where can I specify the Cluster name in the script ?
You can do something like this
foreach($hba in Get-Cluster -Name $clusterName | Get-VMHost | Get-VMHostHba -Type FibreChannel){
$storSys = Get-View -Id $hba.VMHost.ExtensionData.ConfigManager.StorageSystem
$storSys.RescanHba($hba.Device)
$hba | Select @{N='VMHost';E={$_.VMHost.Name}},Name
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You are simply Superb