i see in the powercli realse notes the issue
Get-ScsiLun
Get-ScsiLun
to retrieve Powerpath devices, the value of their MultipathPolicy
property is shown as Unknown
i try to create some batch file or PS1 from the rpowermt side
i will update for all EMC PP\VE users
ok guys
bad news
from PPVE side you can see only one host scsi info
PS C:\Users\liavk> rpowermt display host=myesxhost
CLARiiON logical device count=108
==============================================================================
----- Host Bus Adapters --------- ------ I/O Paths ----- ------ Stats ------
### HW Path Summary Total Dead IO/Sec Q-IOs Errors
==============================================================================
1 vmhba1 optimal 216 0 - 0 0
2 vmhba0 optimal 216 0 - 0 0
i wish on next powercli version they get over the PowerPath "feature"
does this script works for powerCLI version 5.1 ?
Hi Albert,
its work also on 5.1
Rob,
Thanks for the script, but is there any reason as to why the targets and paths is shown as 0 ?
VMHost : PRODESXi01.domain.com
HBA : vmhba0
Targets : 0
Devices : 80
Paths : 0
VMHost : PRODESXi01.domain.com
HBA : vmhba1
Targets : 0
Devices : 80
Paths : 0
VMHost : PRODESXi02.domain.com
HBA : vmhba0
Targets : 0
Devices : 80
Paths : 0
VMHost : PRODESXi02.domain.com
HBA : vmhba0
Targets : 0
Devices : 80
Paths : 0
my PowerCLI version is as follows:
PowerCLI Version
----------------
VMware vSphere PowerCLI 5.1 Release 2 build 1012425
---------------
Snapin Versions
---------------
VMWare AutoDeploy PowerCLI Component 5.1 build 768137
VMWare ImageBuilder PowerCLI Component 5.1 build 768137
VMware License PowerCLI Component 5.1 build 669840
VMware VDS PowerCLI Component 5.1 build 1012428
VMware vSphere PowerCLI Component 5.1 build 1012428
and also the format is not in table format, it would be great if the output is in the table or in CSV if possible.
Luc,
Is there any way to show the Host name on the script result ?
because the result is hard to understand with the following:
vmhba1 Targets: 2 Devices: 80 Paths: 160
vmhba2 Targets: 2 Devices: 80 Paths: 160
vmhba1 Targets: 2 Devices: 80 Paths: 160
vmhba2 Targets: 2 Devices: 80 Paths: 160
vmhba1 Targets: 2 Devices: 80 Paths: 160
vmhba2 Targets: 2 Devices: 80 Paths: 160
vmhba1 Targets: 2 Devices: 8 Paths: 16
vmhba2 Targets: 2 Devices: 8 Paths: 16
vmhba1 Targets: 2 Devices: 8 Paths: 16
vmhba2 Targets: 2 Devices: 8 Paths: 16
vmhba3 Targets: 2 Devices: 8 Paths: 16
vmhba4 Targets: 2 Devices: 8 Paths: 16
...
Thanks in advance.
Use this for esx 5 and above. pretty fast
param($VMHost)
Get-VMHost $VMHost | % {
$VMHost =$_
$details= (Get-EsxCli -VMHost $VMHost).storage.core.path.list() | ? DeviceDisplayName -like "*Fibre Channel*"
$vmhba0 = $details | ? Adapter -like "*vmhba0*" | measure-object | select Count
$vmhba1 = $details | ? Adapter -like "*vmhba1*" | measure-object | select Count
$vmhba2 = $details | ? Adapter -like "*vmhba2*" | measure-object | select Count
$vmhba3 = $details | ? Adapter -like "*vmhba3*" | measure-object | select Count
$vmhba4 = $details | ? Adapter -like "*vmhba4*" | measure-object | select Count
New-Object PSObject |
Add-Member -pass NoteProperty Name $VMHost.Name |
Add-Member -pass NoteProperty Version $VMHost.Version |
Add-Member -pass NoteProperty Build $VMHost.build |
Add-Member -pass NoteProperty Paths $details.count |
Add-Member -pass NoteProperty vmhba0 $vmhba0.count |
Add-Member -pass NoteProperty vmhba1 $vmhba1.count |
Add-Member -pass NoteProperty vmhba2 $vmhba2.count |
Add-Member -pass NoteProperty vmhba3 $vmhba3.count |
Add-Member -pass NoteProperty vmhba4 $vmhba4.count
} | Sort Name |ft -a
Output
Name Version Build Paths vmhba0 vmhba1 vmhba2 vmhba3 vmhba4
---- ------- ----- ----- ------ ------ ------ ------ ------
meda0101esx.meda 5.1.0 1483097 880 220 220 220 220 0
meda0102esx.meda 5.1.0 1483097 880 220 220 220 220 0
meda0103esx.meda 5.1.0 1483097 880 220 220 220 220 0
meda0104esx.meda 5.1.0 1483097 880 220 220 220 220 0
meda0105esx.meda 5.1.0 1483097 880 220 220 220 220 0
meda0106esx.meda 5.1.0 1483097 880 220 220 220 220 0
Sorry to revive an old thread but I am trying to adapt this script so that I can export it to a CSV in a table format for all of my hosts. I have borrowed parts of another script I had that I thought created an object that could be exported to CSV but I am not getting anything on the output and the CSV created is empty. Can anyone see what is going wrong? Feel free to laugh at my attempt if it was never going to work (as long as you provide a solution 😉
ForEach ($Datacenter in (Get-Datacenter | Sort-Object -Property Name)) {
ForEach ($Cluster in ($Datacenter | Get-Cluster | Sort-Object -Property Name)) {
ForEach ($esx in ($Cluster | Get-VMhost | Sort-Object -Property Name)) {
foreach($hba in (Get-VMHostHba -VMHost $esx -Type "FibreChannel")){
$target = ($hba.VMhost.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -eq $hba.Key}).Target
$luns = Get-ScsiLun -Hba $hba
$nrPaths = ($target | %{$_.Lun.Count} | Measure-Object -Sum).Sum
Select-Object -Property @{N="Cluster";E={$esx.parent.name}},
@{N="Host";E={$esx.name}},
@{N="HBA";E={$hba.device}},
@{N="Targets";E={$target.count}},
@{N="Devices";E={$luns.count}},
@{N="Paths";E={$nrpaths}}
}
}
}
}
Cheers
The reason you don't see anything in the CSV file is because the Foreach doesn't place anything on the pipeline.
You can fix that by using the call operator (&).
&{
# Your script
} | Export-Csv report.csv -NoTypeInformation -UseCulture
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
yes, you are right, the result in the CSV file is empty.
What script did you end up using? Also looking to inventory our targets, devices, and paths before storage changes this weekend.
Hi,
Some environmental info:
ESXi and vCenter version: 5.0
Powershell:
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1
PowerCLI Version:
VMware vSphere PowerCLI 6.0 Release 1 build 2548067
I came to this same requirement. I tried to improved the codes in this thread and came up with this:
$vCenter = Read-Host "vCenter IP "
$outputFile = "c:\temp\FCPathCount-of-Hosts-in-$vCenter_" + (get-date -Format yyyy-MM-dd-HHmm) + ".csv"
Connect-VIServer $vCenter
$report = @()
ForEach ($Datacenter in (Get-Datacenter | Sort-Object -Property Name)) {
ForEach ($Cluster in ($Datacenter | Get-Cluster | Sort-Object -Property Name)) {
ForEach ($esx in ($Cluster | Get-VMhost | Sort-Object -Property Name)) {
foreach($hba in (Get-VMHostHba -VMHost $esx -Type FibreChannel)){
$target = ($hba.VMhost.ExtensionData.Config.StorageDevice.ScsiTopology.Adapter | where {$_.Adapter -eq $hba.Key}).Target
$luns = Get-ScsiLun -Hba $hba
$nrPaths = ($target | %{$_.Lun.Count} | Measure-Object -Sum).Sum
$row = "" | select Cluster, VMHost, vmhba, Targets, Devices, Paths
$row.Cluster = $Cluster.Name
$row.VMHost = $esx.Name
if ($hba.ExtensionData.Status -eq "online") {
if ($row.vmhba -eq $null) {
$row.vmhba = $hba.Device
$row.Targets = $target.count
$row.Devices = $luns.count
$row.Paths = $nrpaths
} elseif ($row.vmhba -eq $null) {
$row.vmhba = $hba.Device
$row.Targets = $target.count
$row.Devices = $luns.count
$row.Paths = $nrpaths
}
$report += $row
}
}
}
}
}
$report | Export-Csv -Path $outputFile -NoTypeInformation -UseCulture