Below are a few lines of code that can be added to any script to find out how long it takes your script to complete.
## Begin the timer. $StartTime = (Get-Date) ## Begining of code. hostname ; Get-Counter -Counter "\Memory\Available MBytes" -SampleInterval 1 -MaxSamples 3 ## End of code ## Stop timer. $EndTime = (Get-Date) ## Calculate amount of seconds your code takes to complete. "Elapsed Time: $(($EndTime - $StartTime).totalseconds) seconds"