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
}}
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
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
Thank you!
That exactly what I was trying to do