Saturday 2 May 2009

Get-StopWatchProperties.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     Gets and displays properties of a stopwatch 
  4. .DESCRIPTION 
  5.     This script, written as an MSDN Sample, creates and starts a stop watch. The 
  6.     script stops the stopwatch, and displays the properties. To some degree, the  
  7.     results indicate how long it takes to start and stop a stopwatch. Also, the 
  8.     runtimes vary if you run it multiple times.  
  9. .NOTES 
  10.     File Name  : Get-StopWatchProperties.ps1 
  11.     Author     : Thomas Lee - tfl@psp.co.uk 
  12.     Requires   : PowerShell V2 CTP3 
  13. .LINK
  14.     Original sample posted at: http://pshscripts.blogspot.com/2009/05/get-stopwatchpropertiesps1.html
  15.     MSDN Sample posted at: http://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch_properties.aspx  
  16. .EXAMPLE 
  17.     PSH [C:\foo]: .\Get-StopWatchProperties.PS1' 
  18.     IsRunning           : False 
  19.     Elapsed             : 00:00:00.0000162 
  20.     ElapsedMilliseconds : 0 
  21.     ElapsedTicks        : 233 
  22.   
  23. #> 
  24.   
  25. ## 
  26. # Start of script 
  27. # 
  28.    
  29. # Create and start a stopwatch 
  30.    
  31. $StopWatch = New-Object System.Diagnostics.Stopwatch 
  32.   
  33. # Now start, then stop, the stopwatch 
  34. $StopWatch.start() 
  35. $StopWatch.stop() 
  36.    
  37. # Display results 
  38.    
  39. $stopwatch | Format-List
  40. # End of Script 

No comments: