jueves, 9 de abril de 2020

WINDOWS. PS. Check URL list connections and response times

Purpose


How to verifly a URL list connections and response times

Steps

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:

lunes, 6 de abril de 2020

WINDOWS. Ping Port Continuous

Purpose


How to we can verify different ports are open or close continuously or in real time.

There are a lot of ways for this task I explain someone.


Steps

Command: paping

It's free and not required installation

Download in: https://code.google.com/archive/p/paping/downloads




Command (cmd): paping   x.x.x.x -p PORT



Command (PowerShell): paping   x.x.x.x -p PORT

With PS we have a little commands for add data and tieme

 Command (PowerShell):  .\paping.exe X.X.X.X -p 53 | Foreach{"{0} - {1}" -f (Get-Date),$_}


Check at Windows 
by GoN | Published: April 7, 2020 | Last Updated: