Reputation: 1749
We have an old server and some software on there appears to be exhausting the ports, so we were trying to follow some documentation to track down the culprit. I'm keen to try the PowerShell Get-NetTCPConnection to see if something we have control over is hogging them. The documentation below states that on Windows Server 2008 R2 PowerShell can be updated to include the command, but I'm struggling to find the update that does it.
With PowerShell 5.1 I'm getting the below:
PS C:\> Get-NetTCPConnection
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:1
+ Get-NetTCPConnection
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-NetTCPConnection:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
https://learn.microsoft.com/en-us/windows/client-management/troubleshoot-tcpip-port-exhaust#troubleshoot-port-exhaustion states - "For Windows 7 and Windows Server 2008 R2, you can update your PowerShell version to include the above cmdlet [Get-NetTCPConnection]."
We're running PowerShell 5.1.
I tried adding the NetTCPIP module using the PowerShell command line Install-Module -Name NetTCPIP
, but this didn't work for me either.
What am I missing?
PS C:\> $host
Name : ConsoleHost
Version : 5.1.14409.1005
InstanceId : 6b4acbbe-854d-42bd-b8a0-3685836fa9fb
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-GB
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled : True
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Upvotes: 0
Views: 3553
Reputation: 180
The Microsoft Doc also says the following:
For Windows 7 and Windows Server 2008 R2, you can use the below script to collect the netstat output at defined frequency. From the outputs, you can see the port usage trend.
@ECHO ON
set v=%1
:loop
set /a v+=1
ECHO %date% %time% >> netstat.txt
netstat -ano >> netstat.txt
PING 1.1.1.1 -n 1 -w 60000 >NUL
goto loop
Have you tried this already?
Upvotes: 0