Processes, services and network
Processes
Section titled “Processes”Get-Process # allGet-Process -Name chrome # by nameGet-Process -Id 1234Stop-Process -Name notepad # kill by nameStop-Process -Id 1234 -ForceStart-Process notepad .\notes.txtStart-Process powershell -Verb RunAs # open an administrator PowerShellServices
Section titled “Services”Get-Service # allGet-Service | Where-Object Status -eq RunningGet-Service -Name *sql* # search by nameStart-Service -Name MSSQLSERVER # these three need an administrator PowerShellStop-Service -Name MSSQLSERVERRestart-Service -Name MSSQLSERVERStartup type (automatic, manual, disabled):
Get-CimInstance Win32_Service -Filter "Name='MSSQLSERVER'" | Select-Object Name, StartMode, StateSet-Service -Name MSSQLSERVER -StartupType ManualNetwork
Section titled “Network”Get-NetIPAddress -AddressFamily IPv4 | Select-Object InterfaceAlias, IPAddressResolve-DnsName dumdocentdiscunt.com # like nslookup / digTest-NetConnection google.com # pingTest-NetConnection dbserver -Port 1433 # is that TCP port reachable?Test-NetConnection returns TcpTestSucceeded : True when the port answers.
Which process is using a port
Section titled “Which process is using a port”Ports your machine is listening on:
Get-NetTCPConnection -State Listen | Sort-Object LocalPort | Select-Object LocalAddress, LocalPort, OwningProcessWho is holding port 8080:
$p = Get-NetTCPConnection -LocalPort 8080 -State ListenGet-Process -Id $p.OwningProcessThe classic netstat -ano | findstr :8080 still works too.