cancel
Showing results for 
Search instead for 
Did you mean: 
lag
Level 12

Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

I have a powershell script that I'm trying to convert into a monitor for SAM, but am running into some issues. I'm hoping the community can point me in the right direction. To run this script locally, I have launch powershell with Run As Admin. I've tried putting this into SAM to run locally, and run remotely without any success. The basic script (for run locally) is:

$netstat    = Invoke-Command -Computer $computer -ScriptBlock{

        (netstat -an | Select-String -Pattern '17777' | Measure-Object ).COUNT

        }

Write-Output "Statistic: $netstat"

Write-Output "Message: $netstat pattern matches found"

I've also tried using the Remote Host execution method with the necessary modifications to the script without any luck.

Ultimately what I'm trying to do is count the number of TCP connections for a specific application port. What happens is that the service itself continues to run, or appear to run, even though it's stopped handling the application jobs. Having this monitor would point us in the right direction, saving some trouble shooting steps. It would also be an interesting way to track application usage.

10 Replies
kokso
Level 9

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

Hi, try to setup your powershell monitor following way.

netstat.png

0 Kudos
lag
Level 12

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

No luck that way, or with using HTTPS protocol.

Highlighted
aLTeReGo
Level 21

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

Might I suggest using one of the following templates instead?

lag
Level 12

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

These are a little too generic for my purposes as I need to be able to lock it into a specific port (I'm using the SNMP based TCP connections for all my Winboxes already =)). The WMI monitor gives me an idea, though. Off hand, do you know if this will provide a way to filter on ports if I were to go the WQL route? I haven't had the chance to go poke around the counters yet.

aLTeReGo
Level 21

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

You cannot filter based on port using WQL. You would need to use something like PowerShell. The following templates might be more what you're looking for.

lag
Level 12

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

Bookmarked. Ultimately, it looks like I'm going to have to troubleshoot why WinRM isn't working. Thanks for the quick responses!

aLTeReGo
Level 21

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

That, or install an agent on the endpoint and use local PowerShell. No WinRM required.

0 Kudos
lag
Level 12

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

Another mark for pushing the upgrade through. =D

On a semi-related topic, do you have any idea if the next NCM update will be out this quarter? I'm waiting on that before pushing everything up to the current release here.

0 Kudos
tomasv
Level 12

Re: Need some help with Powershell remote execution... (or another way to measure active network connections on a remote server)

What exact error do you receive, when the PS script runs remotely?

Does it run and returns it wrong values or does it fail?

0 Kudos