I would now propose to take the next step and include a PowerCLI cmdlet.
Something like this
Get-View -ViewType "HostSystem" -property Name | Select Name | Export-Csv C:\Scripts\HostsUpTime.csv
I just noticed, you don't seem to have a
add-pssnapin VMware.VimAutomation.Core
in your script. Did you leave that out on purpose ?
If the snapin is not loaded you will not be able to use PowerCLI cmdlets.