Admins Toolbox – PowerShell Execution Time
By Steve Bowman
Published October 17, 2016
Estimated Reading Time: < 1 minute

Hello again have you ever wondered how long it took to execute a powershell script or command?

With a few lines of code we can retrieve that information from your history.

We can pull from history the last executed command and set it as a variable.

$command = Get-History -Count 1 

Using builtin property’s EndExecutionTime and StartExecutionTime we can determine the execution time.

powershell-execution-getmember

Now subtract EndExecution from StartExecutionTime.

$command.EndExecutionTime – $command.StartExecutionTime

powershell-execution-time

Now go forth and execute.

Post Tags:
Article By Steve Bowman
Steve Bowman is a Partner at Model Technology as well as their Vice President of Sales and Marketing. Steve is a father, husband, Franciscan, and lover of technology. He's bilingual in business and technology and have over 30 years of experience in selling enterprise technology solutions in a variety of industries.

Related Posts