Hi,
Please help, how can I get the vCenter, Cluster, Host and LUN ID in the output.
Please help.
Script
$clusterName = 'Compute'
$report = foreach($esx in (Get-Cluster -Name $clusterName | Get-VMHost)){
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.vmfs.extent.list.invoke() | %{
$obj = $esxcli.storage.core.device.list.CreateArgs()
$obj.device = $_.DeviceName
$esxcli.storage.core.device.list.Invoke($obj)
$esxcli.system.hostname.get()
}
}
$report | Select Device,Size,NoofoutstandingIOswithcompetingworlds | ft -auto
You could do something like this
$report = @()
Get-Cluster -Name $clusterName -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.vmfs.extent.list.invoke() | %{
$obj = $esxcli.storage.core.device.list.CreateArgs()
$obj.device = $_.DeviceName
$path = $esxcli.storage.core.path.list.Invoke($obj)
$esxcli.storage.core.device.list.Invoke($obj) |
ForEach-Object -Process {
$dev = $_
$ds = (Get-Datastore -RelatedObject $esx) |
where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}
$report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |
Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |
Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru |
Add-Member -MemberType NoteProperty -Name Datastore -Value $ds.Name -PassThru |
Add-Member -MemberType NoteProperty -Name LUN -Value (($path.LUN | Sort-Object -Unique) -join '|') -PassThru
}
}
}
$report | Select Device,Size,NoofoutstandingIOswithcompetingworlds | ft -auto
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Not sure what you mean by "LUN Id"?
The other properties can be added like this
$report = @()
Get-Cluster -Name $clusterName -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.vmfs.extent.list.invoke() | %{
$obj = $esxcli.storage.core.device.list.CreateArgs()
$obj.device = $_.DeviceName
$esxcli.storage.core.device.list.Invoke($obj) |
ForEach-Object -Process {
$report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |
Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |
Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru
}
}
}
$report | Select Device,Size,NoofoutstandingIOswithcompetingworlds | ft -auto
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I was referring LUN ID or LUN number to below screenshot
Try like this
$report = @()
Get-Cluster -Name $clusterName -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.vmfs.extent.list.invoke() | %{
$obj = $esxcli.storage.core.device.list.CreateArgs()
$obj.device = $_.DeviceName
$path = $esxcli.storage.core.path.list.Invoke($obj)
$esxcli.storage.core.device.list.Invoke($obj) |
ForEach-Object -Process {
$report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |
Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |
Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru |
Add-Member -MemberType NoteProperty -Name LUN -Value $path.LUN -PassThru
}
}
}
$report | Select Device,Size,NoofoutstandingIOswithcompetingworlds | ft -auto
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Now, I am seeing the LUN number or ID but it is showing multiple times as below
{253, 253, 253, 253}
vCenter Cluster VMHost LUN Device Size DeviceMaxQueueDepth NoofoutstandingIOswithcompetingworlds
------- ------- ------ --- ------ ---- ------------------- -------------------------------------
10.10.10.12 Compute 10.10.11.11 {253, 253, 253, 253} naa.60024xxxxxxxxxxxxxxxxxxxxxxxxxxx 5120 128 128
vCenter Cluster VMHost LUN Device Size DeviceMaxQueueDepth NoofoutstandingIOswithcompetingworlds
------- ------- ------ --- ------ ---- ------------------- -------------------------------------
172.25.255.176 AUR-Compute 172.25.255.112 {253, 253, 253, 253} naa.624a9370427be350aef744380001101b 5120 128 128
Try replacing that line with
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked....Thank you LucD.
One last thing, is there a way to get the datastore name using the naa in this script?
You could do something like this
$report = @()
Get-Cluster -Name $clusterName -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.storage.vmfs.extent.list.invoke() | %{
$obj = $esxcli.storage.core.device.list.CreateArgs()
$obj.device = $_.DeviceName
$path = $esxcli.storage.core.path.list.Invoke($obj)
$esxcli.storage.core.device.list.Invoke($obj) |
ForEach-Object -Process {
$dev = $_
$ds = (Get-Datastore -RelatedObject $esx) |
where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}
$report += Add-Member -InputObject $_ -MemberType NoteProperty -Name vCenter -Value (([uri]$esx.ExtensionData.Client.ServiceUrl).Host) -PassThru |
Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name -PassThru |
Add-Member -MemberType NoteProperty -Name VMHost -Value $esx.Name -PassThru |
Add-Member -MemberType NoteProperty -Name Datastore -Value $ds.Name -PassThru |
Add-Member -MemberType NoteProperty -Name LUN -Value (($path.LUN | Sort-Object -Unique) -join '|') -PassThru
}
}
}
$report | Select Device,Size,NoofoutstandingIOswithcompetingworlds | ft -auto
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That worked Perfectly. Thank you very much