I am trying to write a PowerShell 5.1 script for monitoring jobs. I am having a problem writing a proper Get-Job table, the following is what I have.
Get-Job | Format-Table -AutoSize -Property name, state, @{name = 'Runtime'; Expression = {$((get-date)-($_.psbegintime)).ToString('HH:mm')}}
What this code returns is a table of named jobs and states, but does populate the runtime column. It works if I remove the .ToString('HH:mm')
from the code but that populates the runtime column with Hour:Minute:Second:Millisecond in this format HH:mm:ss:fffffff. How do I remove the Seconds and Milliseconds part?