Hey All, I created the below PowerShell script. What we THINK it’s doing, is looping through all 14 hops between us and an ip address. I believe this is a very general statement and we aren’t really sure what our results mean. I’m hoping someone can help explain what exactly the Test-NetConnection function does, and what does it do when you use the -Hops parameter. We’re using this to help diagnose a connectivity problem between us and a vendor. Please let me know if I can add anymore information to make this easier to diagnose!
function FUNCTION-NAME {
[CmdletBinding()]
Param (
[int]$Hop
)
$test = Test-NetConnection *ip address* -Hops $Hop -InformationLevel Quiet
If ($test -eq $true) {
return $true
} else {
Write-Host "HOP $hop FAILED FOR IP ADDRESS $($Data.TraceRoute[$hop - 1]) AT $((Get-Date).ToString())" -ForegroundColor Red
if (Test-Path -Path "Path to somewhere") {
if (Test-Path -Path "Path to somewhere") {
# Add content
Add-Content -Path "Path to somewhere" -Value "HOP $hop FAILED FOR IP ADDRESS $($Data.TraceRoute[$hop - 1]) AT $(Get-Date)`n`n"
} Else {
# Add txt file and content
New-Item -Path "Path to somewhere" -ItemType File
Add-Content -Path "Path to somewhere" -Value "HOP $hop FAILED FOR IP ADDRESS $($Data.TraceRoute[$hop - 1]) AT $(Get-Date)`n`n"
}
} Else {
# Add user folder, txt file and content
New-Item -Path "Path to somewhere" -ItemType Directory
New-Item -Path "Path to somewhere" -ItemType File
Add-Content -Path "Path to somewhere" -Value "HOP $hop FAILED FOR IP ADDRESS $($Data.TraceRoute[$hop - 1]) AT $(Get-Date)`n`n"
}
return $false
}
}
$count = 1
$Data = Test-NetConnection *ip address* -TraceRoute
Do {
For ($hop = 1; $hop -lt 15; $hop++) {
$Result = FUNCTION-NAME -Hop $hop
If ($Result -eq $false) {
Write-Host "Attempt $count has a failure! It has been logged under Path to somewhere" -ForegroundColor Red
}
}
Write-Host "Attempt $count completed" -ForegroundColor Green
$count++
} while ($True)
The logging does show that there are failures at every hop along the way, and this is intermittent. But we want to better understand what these results mean, so thank you in advance! I have obviously removed any sensitive information. The below are two lines of text which are examples of what a failure will return. Again, we have seen it fail at every hop at least once.
HOP 10 FAILED FOR IP ADDRESS *ip address* AT 07/24/2018 17:01:20 HOP 9 FAILED FOR IP ADDRESS *ip address* AT 07/24/2018 17:01:27