srinivasaddagat
Contributor
Contributor

get storage adapter details using powershell

Jump to solution

Hi,

I am looking for ways to get complete details of the storage adapters on my ESX box. I came across below below script but it gives the target iqn details where as i need host iqn details, is it possible to get this information?

$esxImpl = Get-VMHost -Name

$storImpl = Get-VMHostStorage -VMHost $esxImpl

$stor = get-view $storImpl.ID

foreach($adapter in $stor.StorageDeviceInfo.ScsiTopology.Adapter){

Write-Host $adapter.Adapter

foreach($target in $adapter.Target){

Write-Host $target.Transport.IScsiName

}

}

Thanks

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

Sure, that info is in the same object, different property.

Try this adapted script. Should give you a better overview of your iSCSI topology.

$stor = get-view (Get-VMHostStorage -VMHost (Get-VMHost -Name <ESX-hostname>)).ID

$stor.StorageDeviceInfo.HostBusAdapter | where {$_.GetType().Name -eq "HostInternetScsiHba"} | %{
  Write-Host "Device" $_.Device "iSCSI" $_.IScsiName
  $device = $_.Device
  $stor.StorageDeviceInfo.ScsiTopology.Adapter | where {$_.Adapter -like ("*" + $device)} | %{
  	 $_.Target | %{
	   Write-Host "`tTarget" $_.Target
	   Write-Host "`tIScsiName" $_.Transport.IScsiName
	 }
  }
}


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

View solution in original post

0 Kudos
7 Replies
LucD
Leadership
Leadership

Sure, that info is in the same object, different property.

Try this adapted script. Should give you a better overview of your iSCSI topology.

$stor = get-view (Get-VMHostStorage -VMHost (Get-VMHost -Name <ESX-hostname>)).ID

$stor.StorageDeviceInfo.HostBusAdapter | where {$_.GetType().Name -eq "HostInternetScsiHba"} | %{
  Write-Host "Device" $_.Device "iSCSI" $_.IScsiName
  $device = $_.Device
  $stor.StorageDeviceInfo.ScsiTopology.Adapter | where {$_.Adapter -like ("*" + $device)} | %{
  	 $_.Target | %{
	   Write-Host "`tTarget" $_.Target
	   Write-Host "`tIScsiName" $_.Transport.IScsiName
	 }
  }
}


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

View solution in original post

0 Kudos
srinivasaddagat
Contributor
Contributor

Hi,

It worked perfectly fine. One last thing, will i be able to get IP address details as well? If yes then whats the variblae that host this info. I tried $_.IP, $_.IPSettings, $_.IPAddress but no luck.

Thanks

0 Kudos
LucD
Leadership
Leadership

In the HostInternetScsiTargetTransport object there is a property address that should contain an array with the IP addresses.

Try this


$stor = get-view (Get-VMHostStorage -VMHost (Get-VMHost -Name <ESX-hostname>)).ID

$stor.StorageDeviceInfo.HostBusAdapter | where {$_.GetType().Name -eq "HostInternetScsiHba"} | %{
  Write-Host "Device" $_.Device "iSCSI" $_.IScsiName
  $device = $_.Device
  $stor.StorageDeviceInfo.ScsiTopology.Adapter | where {$_.Adapter -like ("*" + $device)} | %{
  	 $_.Target | %{
	   Write-Host "`tTarget" $_.Target
	   Write-Host "`tIScsiName" $_.Transport.IScsiName
	   foreach($ip in $_.Transport.address){
	   	  Write-Host "`tIP addr" $ip
	   }
	 }
  }
}


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

0 Kudos
srinivasaddagat
Contributor
Contributor

Hi,

Thanks. I should have been more specific, i am looking for IP addresses

assigned to my HBA adapters and not the target IP address. I jus tried

$_.address along with $_.Device and $_.IscsiAlias but it doesn't seem to

work.

Thanks

Srinivas

0 Kudos
LucD
Leadership
Leadership

The IP properties of the HBA can be found in the HostInternetScsiHbaIPProperties object which is accessible from the ipProperties property in the HostInternetScsiHba object.

$stor = get-view (Get-VMHostStorage -VMHost (Get-VMHost -Name <ESX-hostname>)).ID

$stor.StorageDeviceInfo.HostBusAdapter | where {$_.GetType().Name -eq "HostInternetScsiHba"} | %{
  Write-Host "Device" $_.Device "iSCSI" $_.IScsiName
  Write-Host "IP properties"
  Write-Host "`tIP address" $_.ipProperties.address
  Write-Host "`tMAC address" $_.ipProperties.mac
  Write-Host
  $device = $_.Device
  $stor.StorageDeviceInfo.ScsiTopology.Adapter | where {$_.Adapter -like ("*" + $device)} | %{
  	 $_.Target | %{
	   Write-Host "`tTarget" $_.Target
	   Write-Host "`tIScsiName" $_.Transport.IScsiName
	   foreach($ip in $_.Transport.address){
	   	  Write-Host "`tIP addr" $ip
	   }
	 }
  }
}


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

rajesh1976
Contributor
Contributor

Hi,

Need to get the storage adaptert hardware details like firmware version, driver version etc using shell script. Anyone please help me ?

Regards,

Rajesh

0 Kudos
LucD
Leadership
Leadership

I replied in your thread.

____________

Blog: LucD notes

Twitter: lucd22


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

0 Kudos