#Get-NetTCPConnection
Explore tagged Tumblr posts
fluk3sake · 3 years ago
Text
Find which program is using a Specific Port in Windows
Find which program is using a Specific Port in Windows
While installing a web server on a workstation, I kept getting an error that the port number was in use. This obviously caused some issues as it is an IT machine, who knows what was installed using the ports? There are two ways to figure out what software is using the ports required. The first is Command Prompt which is a Legacy way of doing it but still works fine.Secondly is with PowerShell…
Tumblr media
View On WordPress
1 note · View note
rishushaw · 3 years ago
Text
Here is the 28 windows cmd commands that will increase your productivity level
1. ipconfig - Get-NetIPAddress
2. ipconfig /all - Get-NetIPConfiguration (only shows DNS-Server and Gateway)
3. findstr - Select-String
4. ipconfig /release - no equivalent afaik
5. ipconig /renew - no equivalent afaik
6. ipconfig /displaydns - Get-DnsClientCache (you may use '| Format-List' to get all colums)
7. clip - Set-Clipboard
8. ipconfig /flushdns - Clear-DnsClientCache
9. nslookup - Resolve-DnsName
10. cls - Clear-Host (or just Ctrl+L)
11. getmac /v - Get-NetAdapter
12. powercfg - no equivalent afaik
13. assoc - no equivalent afaik (also assoc does not seem to exist on my Windows 11 21H2 VM)
14. chkdsk - Repair-Volume
15. sfc - no equivalent afaik
16. DISM - no equivalent afaik
17. tasklist - Get-Process
18. taskkill - Stop-Process
19. netsh - no equivalent afaik but you can manipulate the Windows firewall, just search with Get-Command firewall
20. ping - Test-NetConnection
21. ping /t - Test-Connection -Count 100000 (Test-Connection gives you much more data, while Test-NetConnection just shows the IP and Latency to the target)
22. tracert - Test-NetConnection -TraceRoute
23. netstat - Get-NetTCPConnection
24. route print - Get-NetRoute
25. route add - New-NetRoute
26. route delete - Remove-NetRoute
27. shutdown - Stop-Computer
28. restart - Restart-Computer
18 notes · View notes
jesusninoc · 7 years ago
Text
Ejecutar el cmdlet Get-NetTCPConnection de PowerShell en PHP
Ejecutar el cmdlet Get-NetTCPConnection de PowerShell en PHP
"" | .\php.exe
View On WordPress
0 notes
kfalconspb · 8 years ago
Link
The new netstat: Playing with Get-NetTCPConnection https://t.co/oCJWqeuHiS #ifh For some reason, I don’t like netstat. Never did. Fortunat…
0 notes
pewa2303-blog · 8 years ago
Text
For some reason, I don’t like netstat. Never did. Fortunately PowerShell provides a similar command to netstat: Get-NetTCPConnection. Let’s discover the options of this command in form of this blog post.
Get-NetTCPConnection
Running without any parameter it gives you an overview of all TCP Connections. It will show you TCP Connections of all states (closed, waiting, listening, established …)
Get-NetTCPConnection
Tumblr media
IPv4 only
To show only IPv4 Connections simply provide your Local IPv4 Address. It might be useful to sort on the Local Port:
Get-NetTCPConnection -LocalAddress 192.168.0.100 | Sort-Object LocalPort
Tumblr media
IPv6 only
If you are lucky and your ISP provides you with IPv6 Adresses, then enter your IPv6 Global Unicast Address.
Get-NetTCPConnection -LocalAddress 2a02:8388:b01:3700:215:5dff:fe6f:a00 | Sort-Object LocalPort
Tumblr media
Show established connections only
I guess the most important parameter is state. To show only established connections in a user-friendly view (Format-Table) run
Get-NetTCPConnection -State Established | Format-Table -AutoSize
Tumblr media
Well, ok, we’ve seen in these first steps what Get-NetTCPConnection could do for us. Before we continue to the more advanced part of this post let’s compare the output to netstat.
As I’ve mentioned: The PowerShell cmdlet is my favourite.
Get-NetTCPConnection for Power Users
Resolving IP-Addresses
Do you know the IP of sid-500.com. Why not? 😉 If you don’t know the IP of my site how would you check if you are connected to it? Ok, sure there must be a connection because you’re reading my article. Well, if you know the hostname then run Resolve-DnsName to get the IP-Address!
Get-NetTCPConnection -RemoteAddress (Resolve-DnsName sid-500.com).IPAddress -ErrorAction SilentlyContinue | Format-List
Tumblr media
For this it’s useful to use the Erroraction Parameter for avoiding ugly red error messages. Resolve-DNSName will give you 2 IPv4 Addresses of my site. But you are only connected to one of them. So you are not connected to the other one which causes the red lines.
Look at the following example. Microsoft has more than one Public IPv4 Address. I’m connected to only one of them. If you run this command with Erroraction silentlycontinue, you’ll see no red lines anymore.
Tumblr media
Get TCP Connections on Remote Hosts
If you want to figure out the established TCP Connections on a remote host, simply use Invoke-Command. Note, that I’m logged on dc01. Server02 is the remote host. Both computers share the same domain.
Invoke-Command -ComputerName server02 {Get-NetTCPConnection -State Established}
Tumblr media
Get TCP Connections from all Servers
To retrieve all established connections from all servers of your domain (all OUs!) and to save them all to  a file, run
(Get-ADComputer -Filter 'operatingsystem -like "*server*"').Name | Foreach-Object {Invoke-Command -ComputerName $_ {Get-NetTCPConnection -State Established -ErrorAction SilentlyContinue} | Sort-Object PSComputerName | Select-Object PSComputername, LocalPort, RemotePort, RemoteAddress} | Out-File C:\Temp\TCPConn.txt
Tumblr media Tumblr media
That’s it for today. Hope you enjoyed it!
See also
For more about networking with PowerShell see also my articles
PowerShell: Testing the connectivity to the Default Gateway on localhost and Remote Hosts by reading the Routing Table
PowerShell: Use SSH to connect to remote hosts (Posh-SSH)
PowerShell: Check open/closed ports with Test-NetConnection
The new netstat: Playing with Get-NetTCPConnection For some reason, I don't like netstat. Never did. Fortunately PowerShell provides a similar command to netstat: Get-NetTCPConnection.
0 notes
jesusninoc · 7 years ago
Text
Ejecutar el cmdlet Get-NetTCPConnection de PowerShell en Java
Ejecutar el cmdlet Get-NetTCPConnection de PowerShell en Java
import java.io.IOException; import java.util.concurrent.TimeUnit; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ProcesoPowerShell { public static void main(String[] args) throws InterruptedException { Runtime runtime = Runtime.getRuntime(); try { Process process = runtime.exec("powershell.exe Get-NetTCPConnection");…
View On WordPress
0 notes
jesusninoc · 8 years ago
Text
Comprobar si está abierto un puerto TCP
while(1) { Get-NetTCPConnection | Select-Object LocalAddress,RemotePort,OwningProcess| Where-Object {$_.RemotePort -eq "443"} Start-Sleep -Seconds 5 clear }
View On WordPress
0 notes