VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to get Datastore name in the output

Hi,

I am unable to get Datastore name in the output for below script

Please help

Get-Cluster -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
$myesxcli = Get-EsxCli -VMHost $esx -V2
$myesxcli.storage.core.device.list.Invoke()
$dev = $_
$ds = (Get-Datastore -RelatedObject $esx) | where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}
} | Select @{N="Cluster";E={($Cluster).Name}}, @{N="VMHost";E={$esx.Name}}, Device, @{N="Datastore";E={($ds).Name}}, @{N="SizeGB";E={[math]::round($_.Size/1024)}}, IsPerenniallyReserved, DeviceMaxQueueDepth, NoofoutstandingIOswithcompetingworlds | ft -auto

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You have to loop per device.
Try like this

Get-Cluster -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
    $myesxcli = Get-EsxCli -VMHost $esx -V2
    $myesxcli.storage.core.device.list.Invoke() |
    ForEach-Object -Process {
        $dev = $_
        $ds = (Get-Datastore -RelatedObject $esx) | where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}

        $dev | Select @{N="Cluster";E={($Cluster).Name}}, 
            @{N="VMHost";E={$esx.Name}}, Device, 
            @{N="Datastore";E={($ds).Name}}, 
            @{N="SizeGB";E={[math]::round($_.Size/1024)}}, 
            IsPerenniallyReserved, DeviceMaxQueueDepth, NoofoutstandingIOswithcompetingworlds
    }
} | Format-Table -AutoSize

 


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

You have to loop per device.
Try like this

Get-Cluster -PipelineVariable cluster |
Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
    $myesxcli = Get-EsxCli -VMHost $esx -V2
    $myesxcli.storage.core.device.list.Invoke() |
    ForEach-Object -Process {
        $dev = $_
        $ds = (Get-Datastore -RelatedObject $esx) | where{$_.ExtensionData.Info.Vmfs.Extent.diskname -contains $dev.Device}

        $dev | Select @{N="Cluster";E={($Cluster).Name}}, 
            @{N="VMHost";E={$esx.Name}}, Device, 
            @{N="Datastore";E={($ds).Name}}, 
            @{N="SizeGB";E={[math]::round($_.Size/1024)}}, 
            IsPerenniallyReserved, DeviceMaxQueueDepth, NoofoutstandingIOswithcompetingworlds
    }
} | Format-Table -AutoSize

 


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you... Perfect as always 🙂

0 Kudos