Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Created January 21, 2020 20:24
Show Gist options
  • Save adamdriscoll/87f97b183dec630ccc42588b86a3520d to your computer and use it in GitHub Desktop.
Save adamdriscoll/87f97b183dec630ccc42588b86a3520d to your computer and use it in GitHub Desktop.
Create a script in Universal Automation
$Script = New-UAScript -Name 'Check Website' -ScriptBlock {
$Stopwatch = [System.Diagnostics.Stopwatch]::new()
$Stopwatch.Start()
try
{
$Response = Invoke-WebRequest https://ironmansoftware.com
$ResponseTime = $Stopwatch.ElapsedMilliseconds
}
catch
{
throw "IronmanSoftware.com is down!"
}
if ($Response.StatusCode -ne 200)
{
throw "Status code $($Response.StatusCode)"
}
@{
StatusCode = $Response.StatusCode
ResponseSize = $Response.RawContentLength
ResponseTime = $ResponseTime
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment