VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Get the host name from rescan command

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

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

foreach($hba in 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

View solution in original post

0 Kudos
10 Replies
LucD
Leadership
Leadership
Jump to solution

Does this return the host?

Get-Cluster MyCluster | Get-VMHost | Get-VMHostStorage -RescanAllHba |

Select @{N='VMHost';E={$_.VMHost.Name}},SoftwareScsiEnabled


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Hi LucD,

How can I rescan only fnic or fibre  and get only its output ?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is not a cmdlet nor a cmdlet parameter, but an API method.

Something like this

Get-VMHost | Get-VMHostHba -Type FibreChannel | %{

   $storSys = Get-View -Id $_.VMHost.ExtensionData.ConfigManager.StorageSystem

   $storSys.RescanHba($_.Device)

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

ganapa2000
Hot Shot
Hot Shot
Jump to solution

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}}

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

foreach($hba in 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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

That worked Smiley Happy.

Thank you very much for your help.

One last question, where can I specify the Cluster name in the script ?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can do something like this

$clusterName = 'MyCluster'

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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

You are simply Superb Smiley Happy

0 Kudos