Dmitry Porotnikov / PowerShell: Download and run Sysinternals PSPing to test network connectivity over TCP

Created Tue, 22 Aug 2023 13:45:53 +0000 Modified Tue, 22 Aug 2023 13:45:53 +0000
76 Words

PowerShell: Download and run Sysinternals PSPing to test network connectivity over TCP

# Define the URL and the output file path for PsPing
$pspingURL = "https://live.sysinternals.com/PsPing.exe"
$pspingFilePath = "C:\Temp\PsPing.exe"

# Create the output directory if it doesn't exist
If (!(Test-Path -Path (Split-Path -Path $pspingFilePath))) {
    New-Item -ItemType Directory -Path (Split-Path -Path $pspingFilePath) -Force
}

# Download PsPing
Invoke-WebRequest -Uri $pspingURL -OutFile $pspingFilePath

# Test the connection using PsPing with the -accepteula flag
& $pspingFilePath -accepteula "8.8.8.8:443"