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

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

No more cyber insurance forms!

Tired of filling out endless cyber insurance forms?

  • Download accurate security reports about your environment with a single click.
  • Avoid costly reporting errors.
  • Use your time in better ways.
  • Prove your cyber readiness with confidence.

Download our vCISO platform brochure to learn more.