Hi All,
I am running following script to obtain Lun multipathing info , I need to know how can I add capacity in GB and also if I want to run it at ESXi cluster level.
Get-VMHost | ForEach-Object {
$esxImpl = $_
$esx = Get-View $esxImpl
$esxImpl | Get-VMHostHba | ForEach-Object {
$hba = $_
Get-ScsiLun -Hba $hba | ForEach-Object {
$lun = $_
$scsilun = $esx.Config.StorageDevice.ScsiLun | Where-Object {$_.Key -eq $lun.Key}
$row = "" | Select-Object -Property Host,HBA,Device
$row.Host = $esxImpl.Name
$row.HBA = $hba.Name
$row.Device = $scsilun.CanonicalName
}
$row
}
}
} | Export-Csv -Path HbaDevices.csv -NoTypeInformation -UseCulture
Try like this
$clusterName = 'MyCluster'
$report = foreach($esx in (Get-Cluster -Name $clusterName | Get-VMHost)){
foreach($hba in Get-VMHostHba -VMHost $esx){
foreach($lun in Get-ScsiLun -Hba $hba){
New-Object psobject -Property @{
Host = $esx.Name
HBA = $hba.Name
Device = $lun.CanonicalName
Capacity = $lun.CapacityGB
}
}
}
}
$report | Select Host,HBA,Device,Capacity |
Export-Csv -Path HbaDevices.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
$clusterName = 'MyCluster'
$report = foreach($esx in (Get-Cluster -Name $clusterName | Get-VMHost)){
foreach($hba in Get-VMHostHba -VMHost $esx){
foreach($lun in Get-ScsiLun -Hba $hba){
New-Object psobject -Property @{
Host = $esx.Name
HBA = $hba.Name
Device = $lun.CanonicalName
Capacity = $lun.CapacityGB
}
}
}
}
$report | Select Host,HBA,Device,Capacity |
Export-Csv -Path HbaDevices.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference