Purpose
How to verifly a URL list connections and response times
Steps
How to verifly a URL list connections and response times
Command:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$script:Report = @()
function Get-UrlStatusCode([uri] $Url) {
$datetime = Get-Date
$HostName = $Url.Authority
try {
$ipAddress = [System.Net.Dns]::GetHostAddresses($HostName)[0].IPAddressToString;
}
catch {
$ipAddress = "NOT RESOLVED"
}
$timings = Measure-Command -Expression {
try {
$output = Invoke-WebRequest -Uri $Url -ErrorAction SilentlyContinue -MaximumRedirection 20 -Method GET -TimeoutSec 15;
}
catch {
$output = $_.Exception.Response;
}
}
$checkObject = New-Object PSObject;
#$checkObject | Add-Member -MemberType NoteProperty -Name 'StatusCode' -Value $output.StatusCode;
#$checkObject | Add-Member -MemberType NoteProperty -Name 'StatusDescription' -Value $output.StatusDescription;
$checkObject | Add-Member -MemberType NoteProperty -Name 'HostName' -Value $ipAddress;
$checkObject | Add-Member -MemberType NoteProperty -Name 'TimeStamp' -Value $datetime.ToUniversalTime();
$checkObject | Add-Member -MemberType NoteProperty -Name 'Time' -Value $timings;
$checkObject | Add-Member -MemberType NoteProperty -Name 'URL' -Value $Url;
$script:Report += $checkObject;
Write-Host "$($Url) done in $($timings)"
}
#URL to check:
Get-UrlStatusCode "https://portal.azure.com"
Get-UrlStatusCode "https://dev.azure.com"
Get-UrlStatusCode "https://www.microsoft.com"
Get-UrlStatusCode "https://www.nike.com"
$script:Report | ForEach-Object { [PSCustomObject]$_ } | Format-Table -AutoSize
Save this code in a file.ps1 and execute
Check at Windows
by GoN | Published: April 9, 2020 | Last Updated:
No hay comentarios:
Publicar un comentario