VMware Cloud Community
aktrifekta
Contributor
Contributor
Jump to solution

List Datastore Paths

     Hi Guys,

Im working on modifying a script to provide paths for an entire cluster. I was lucky enough to discover a script that doest what I need, but only for one hosts:

I was wondering if any of you could assist in modifying it to point it to a cluster; there was very little success with the foreach command on my behalf

$esxName = 'name'

$esx = Get-VMHost -Name $esxName

$esxcli = Get-EsxCli -VMHost $esx

$esxcli.storage.vmfs.extent.list() |

Select VolumeName,ExtentNumber,@{N='Device';E={$_.DeviceName}},

    @{N='Path#';E={

        $esxcli.storage.core.path.list($_.DeviceName) | Measure-Object | Select -ExpandProperty Count

    }}

Tags (1)
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

$clusterName = 'MyCluster'

Get-Cluster -Name $clusterName | Get-VMHost | %{

    $esxcli = Get-EsxCli -VMHost $_

    $esxcli.storage.vmfs.extent.list() |

    Select @{N='VMHost';E={$esxcli.VMHost.Name}},

        VolumeName,ExtentNumber,@{N='Device';E={$_.DeviceName}},

        @{N='Path#';E={

            $esxcli.storage.core.path.list($_.DeviceName) | Measure-Object | Select -ExpandProperty Count

        }}

    }


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

$clusterName = 'MyCluster'

Get-Cluster -Name $clusterName | Get-VMHost | %{

    $esxcli = Get-EsxCli -VMHost $_

    $esxcli.storage.vmfs.extent.list() |

    Select @{N='VMHost';E={$esxcli.VMHost.Name}},

        VolumeName,ExtentNumber,@{N='Device';E={$_.DeviceName}},

        @{N='Path#';E={

            $esxcli.storage.core.path.list($_.DeviceName) | Measure-Object | Select -ExpandProperty Count

        }}

    }


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

aktrifekta
Contributor
Contributor
Jump to solution

Thank you!

That exactly what I was trying to do

0 Kudos