Search-IsItUp.psm1
<#
.Synopsis Checks to wee if a website is up .DESCRIPTION Uses the website https://isitup.org to check if the specified website is up or down, and reports the results back .EXAMPLE Search-IsItUp -DomainName powershellgallery.com Yay, powershellgallery.com is up. It took 0.463 seconds to get a 200 status code from an IP address of 40.87.85.101. .EXAMPLE "dailymail.co.uk","thesun.co.uk","news.bbc.co.uk" | Search-IsItUp Yay, dailymail.co.uk is up. It took 0.041 seconds to get a 200 status code from an IP address of 184.30.21.195. Yay, thesun.co.uk is up. It took 0.182 seconds to get a 200 status code from an IP address of 18.66.122.18. Yay, news.bbc.co.uk is up. It took 0.089 seconds to get a 200 status code from an IP address of 151.101.112.81. #> function Search-IsItUp { [CmdletBinding()] Param ( # Domain name like powershellgallery.com [Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)] $DomainName ) Begin { } Process { foreach ($Domain in $DomainName) { try { $data = Invoke-WebRequest -Uri https://isitup.org/$Domain ($data.ToString() -split "[`r`n]" | Select-String $Domain | Select-Object -First 1) -replace "<title>", "" -replace "</title>", "" ($data.ToString() -split "[`r`n]" | Select-String "it took" | Select-Object -First 1) -replace '<p class="smaller">', "" -replace "</p>", "" } catch { $bad = $_ Write-Warning "Something went wrong:- $bad" } } } End { } } |