Powershell time command

March 10, 2022powershell

I commbined the best parts of this StackOverflow answer and this Super User answer to come up with this solution for a time function in Powershell:

function time {
    $Command = "$args";
    (Measure-Command { Invoke-Expression $Command 2>&1 | Out-Default }).ToString();
}

Example usage:

# time git pull
00:00:01.0804938