Skip to content

Processes, services and network

Terminal window
Get-Process # all
Get-Process -Name chrome # by name
Get-Process -Id 1234
Stop-Process -Name notepad # kill by name
Stop-Process -Id 1234 -Force
Start-Process notepad .\notes.txt
Start-Process powershell -Verb RunAs # open an administrator PowerShell
Terminal window
Get-Service # all
Get-Service | Where-Object Status -eq Running
Get-Service -Name *sql* # search by name
Start-Service -Name MSSQLSERVER # these three need an administrator PowerShell
Stop-Service -Name MSSQLSERVER
Restart-Service -Name MSSQLSERVER

Startup type (automatic, manual, disabled):

Terminal window
Get-CimInstance Win32_Service -Filter "Name='MSSQLSERVER'" | Select-Object Name, StartMode, State
Set-Service -Name MSSQLSERVER -StartupType Manual
Terminal window
Get-NetIPAddress -AddressFamily IPv4 | Select-Object InterfaceAlias, IPAddress
Resolve-DnsName dumdocentdiscunt.com # like nslookup / dig
Test-NetConnection google.com # ping
Test-NetConnection dbserver -Port 1433 # is that TCP port reachable?

Test-NetConnection returns TcpTestSucceeded : True when the port answers.

Ports your machine is listening on:

Terminal window
Get-NetTCPConnection -State Listen | Sort-Object LocalPort |
Select-Object LocalAddress, LocalPort, OwningProcess

Who is holding port 8080:

Terminal window
$p = Get-NetTCPConnection -LocalPort 8080 -State Listen
Get-Process -Id $p.OwningProcess

The classic netstat -ano | findstr :8080 still works too.