How to format output to DD, HH, MM
<p>I'm trying to work out a devices up time using PowerShell. My code is as so: </p>

<pre><code>$wmi = Get-WmiObject -Class Win32_OperatingSystem
$upTime = $wmi.ConvertToDateTime($wmi.LocalDateTime) – $wmi.ConvertToDateTime($wmi.LastBootUpTime)
</code></pre>

<p>When I call $upTime, it returns the following:</p>

<pre><code>Days              : 0
Hours             : 1
Minutes           : 8
Seconds           : 5
Milliseconds      : 311
Ticks             : 40853110010
TotalDays         : 0.0472836921412037
TotalHours        : 1.13480861138889
TotalMinutes      : 68.0885166833333
TotalSeconds      : 4085.311001
TotalMilliseconds : 4085311.001
</code></pre>

<p>While I can see the up time, I need to specifically format the output to <strong>D:dd, H:hh, M:mm</strong> as I will be automatically feeding this into a monitoring system, but after much searching on here, google etc, I can't see how to achieve this. Can anyone suggest how to go about doing this?  </p>