This all started from a simple command I ran in another monitoring tool that is being replaced.
netstat -an | find "TCP" | find ":1433" | find /c "ESTABLISHED"
Then I replicated it in powershell:
(Get-NetTCPConnection | Where-Object { $_.RemotePort -eq '1433' -and $_.State -eq 'ESTABLISHED' }).count
I realize that when I get it working in solarwinds port and state should be variables for this I picked a known port for ease of following the thread.
After looking at other examples of Windows PowerShell Monitor
I populated the script body with:
$stat =(Get-NetTCPConnection | Where-Object { $_.RemotePort -eq '1433' -and $_.State -eq 'ESTABLISHED' }).count
Write-Host 'Statistic:' $stat
exit(0)
I get this error:
Output: ==============================================
Statistic:
Errors: ==============================================
Get-NetTCPConnection : The term 'Get-NetTCPConnection' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:9
+ $stat =(Get-NetTCPConnection | Where-Object { $_.RemotePort -eq '1433 ...
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-NetTCPConnection:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I have also tried but failed using Get-Netstat.
Any help or better ideas I would appreciate.
Thank you