powershell commands Flashcards
1
Q
how do you finsd the processes running on a port in powershell
A
Get-NetTCPConnection -LocalPort 3000 | Select-Object -ExpandProperty OwningProcess
Explanation:
Get-NetTCPConnection -LocalPort 3000:
Retrieves network connections using port 3000.
Select-Object -ExpandProperty OwningProcess:
Extracts the process ID (PID) of the process using the port.
2
Q
how do you stop a process on a specific port
A
Stop-Process -Id 24476 -Force -ErrorAction SilentlyContinue
change the number after id with the pid of the process