Hello, I need to list all of my hosts, and the related datastores to each, and also count these datastores per host, but the last part is optional I may do it manually for the sake of making the script simpler now.
Try something like this
ForEach-Object -Process {
$ds = Get-Datastore -RelatedObject $_
$ds | Select @{N = 'VMHost'; E = {$esx.Name}},
@{N = 'TotalDS'; E = {$ds.Count}},
Name
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This command dod the trick, but I still need to count if possible please.
get-vmhost | select name, @{N="Datastore"; E={Get-Datastore -VMHost $_}}
Try something like this
ForEach-Object -Process {
$ds = Get-Datastore -RelatedObject $_
$ds | Select @{N = 'VMHost'; E = {$esx.Name}},
@{N = 'TotalDS'; E = {$ds.Count}},
Name
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That's what I'm talking about. Thank you!