Ok, I know it's possible but need some help on the follow-thru.
I am trying to get a list of hosts in a vcenter with the following columns.
datacenter | cluster | hosts name | uptime in Days
All I have so far is:
Get-VMHost | Get-View | select @{N="Uptime"; E={(Get-Date) - $_.Summary.Runtime.BootTime}}
but that just gives me it in boot time when I need just the number of days.
Also, I need to get this in a .csv. This is what I am coming up with but something is way off here....I am so new to this still and can't put the pieces together. Any help is appreciated.
Get-Cluster |
Select Name,
@{N="Datacenter";E={Get-Datacenter -Cluster $_ | Select -ExpandProperty Name}},
@{N="Hosts";E={$_.ExtensionData.Host.Count}},
@{N="Uptime"; E={$_.ExtensionData.Summary.Runtime.BootTime $end).days}},
Select -ExpandProperty Sum
}} | Export-Csv c:\report2.csv -NoTypeInformation -UseCulture