Measure Website Response Time with Powershell as a Performance Monitor

<#Original script was here

 http://powershell.com/cs/blogs/tips/archive/2015/03/13/measuring-website-response-and-execution-times.aspx

 Tweaked slightly to work with WUG.

 #>

 $url = 'http://google.com'

 # track execution time:

 $timeTaken = Measure-Command -Expression {

 $site = Invoke-WebRequest -Uri $url -UseBasicParsing

 }

 $milliseconds = $timeTaken.TotalMilliseconds

 $milliseconds = [Math]::Round($milliseconds, 0)

 $Context.SetValue($milliseconds);

 write-host $milliseconds


  • Excellent....but can anyone add a way to show a zero ms value when the connection is unreachable to this script? Thanks