When using Powershell I’ve always found it useful to be able to time how long commands/scripts are running for, invaluable when running long-running scripts. I used to do something similar to this in all my scripts:
which is rather crude. It also has the disadvantage that I have to remember to actually put this into my scripts. What I’d prefer would be a way for Powershell to always tell me how long it takes my commands/scripts to run and thanks to my old Conchango colleague Stuart Preston I now have a way. Using Stuart’s code that he has put up in a gist one can have Powershell output this information every time a command is executed:
Note that the current location is still present in the title bar (Stuart’s code does that too) and time elapsed since the last command is displayed. Perfect! Simply put Stuart’s code into your profile and you’re done.
A simple little trick but one which I think its worth calling out in a blog post!