Hi guys,
I am trying to create a bit of code that will give me basic details about datastore space etc, but group it by what esx hosts are attached.
I created a simple array but just dont know how to proceed with grouping it based on attached esx host.
$vmh = get-Cluster | get-VMHost
$ds = @()
foreach ($ho in $vmh | get-Datastore)
{
$my ="" |Select-Object name, FreespaceMB
$my.name = $ho.name
$my.freespacemb = $ho.FreeSpaceMB
$ds += $my
}
Any ideas would be greatly appreciated
thanks
DC
$ds = @() Get-Cluster | Get-VMHost | % { $myHost = $_ $myHost | Get-DataStore | % { $out = "" | Select-Object DSName, FreespaceMB, Host $out.DSName = $_.Name $out.FreespaceMB = $_.FreespaceMB $out.Host = $myHost.Name $ds += $out } } $ds | *Sort* Host
$ds = @() Get-Cluster | Get-VMHost | % { $myHost = $_ $myHost | Get-DataStore | % { $out = "" | Select-Object DSName, FreespaceMB, Host $out.DSName = $_.Name $out.FreespaceMB = $_.FreespaceMB $out.Host = $myHost.Name $ds += $out } } $ds | *Sort* Host
Hi harkamal,
Thanks for the help with this.
It works great.
I appreciate the help.
Regards
DC
welcome
there's another cool cmdlet
$ds | Group Name