Making ConvertToDateTime More Readable?

Hello fine folks of the powershell community. I’m writing a script to get the uptime of all the citrix servers in our farm. This is what I have thus far:

$cred = Get-Credential domainusername $servers = Get-Content C:folderfile.txt $NewCSVObject = @() foreach($server in $servers){ $NewCSVObject+= (Get-WmiObject win32_OperatingSystem - ComputerName $server -Credential $cred| Select-Object @{N="Computer Name"; E={$_.PSComputerName}}, @{N="Operation System"; E={$_.caption}}, @{N="Installed On"; E={$_.convertToDateTime($_.lastBootUpTime)}}, @{N="Uptime"; E={$_.convertToDateTime($_.LocalDateTime)-$_.convertToDateTime ($_.lastBootUpTime)}}, OSArchitecture) } $NewCSVObject | export-csv c:scriptswhateverTheFuck.csv - NoTypeInformation 

Problem is, I get output for the uptime that looks like this: 9.22:02:16.9886850


Is there a way i can make it prettier. Thanks!

submitted by /u/SouthTriceJack
[link] [comments]

Leave a Reply