0

I am trying to monitor a F5 VPN Client running on my Windows 7 laptop when its established connection. I designed a simple Powershell script that would utilize the "netstat" command to look for a certain string variable that is only available when connection is established. I was planning on using Microsoft's Task Scheduler to trigger the script every so often to monitor the connection / string variable.

If I run the following netstat command at the Powershell window, it returns the information just fine:

    PS C:\tmp> $c = netstat -ban | select-string "F5FltSrv"; $c.count
    9

But if I run a similar operator and variables in the Powershell script, it keeps returning '0' (zero), so it fails.

Here's the actual Powershell script I am using:

    $VPN = netstat -ban | select-string "F5FltSvr"

    Write-Host "DEBUG: " $VPN.count

    if($VPN.count -gt 7) {
    Write-Host "F5 VPN Session is enabled." -b Green
    exit
    }
    else {
    Write-Host "F5 VPN Session is down!" -b Red -f Yellow
    }

When executed

    PS C:\tmp> .\F5_VPN_Check.ps1
    0
    F5 VPN Session is down!

Can anyone tell me where I have a fault in the script? The Powershell window is running with Administrator priviledges and UAC is turned off.

1
  • What account are you running this under? Commented Jul 10, 2015 at 1:12

1 Answer 1

1

Could it be a typo? Instead of this:

$VPN = netstat -ban | select-string "F5FltSvr"

You want this:

$VPN = netstat -ban | select-string "F5FltSrv"

At least that is the example you used that worked. Note the diff between Svr and Srv.

Sign up to request clarification or add additional context in comments.

1 Comment

Wow. A typo. That's why its best to have a 2nd pair of eyes. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.