From 82bcdc77f6984810817473d26809932288967348 Mon Sep 17 00:00:00 2001 From: camoy Date: Thu, 15 Aug 2024 18:30:23 -0700 Subject: [PATCH] Functions attempt #2 --- scripts/ps/netcheck.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/ps/netcheck.ps1 b/scripts/ps/netcheck.ps1 index cebc5eb..e477d22 100644 --- a/scripts/ps/netcheck.ps1 +++ b/scripts/ps/netcheck.ps1 @@ -1,8 +1,9 @@ -function fDefaultGatewayCheck { +Function fDefaultGatewayCheck { Write-Host "---Determine Default Gateway---" Get-WmiObject -Class Win32_IP4RouteTable | where { $_.destination -eq '0.0.0.0' -and $_.mask -eq '0.0.0.0' } | Sort-Object nexthop, metric1, interfaceindex $vSCNextHop = (Get-WmiObject -Class Win32_IP4RouteTable | where { $_.destination -eq '0.0.0.0' -and $_.mask -eq '0.0.0.0' } | Sort-Object metric1 | select nexthop | Format-Wide | Out-String).trim() } +fDefaultGatewayCheck() Test-Connection $vSCNextHop if ($? -eq $false) { @@ -31,6 +32,6 @@ Test-Connection $vSCNextHop } else { - fDefaultGatewayCheck + fDefaultGatewayCheck() } }