Skip to main content

Command Reference

Windows — network​

CommandRead this in the output
ipconfig /allIPv4, mask, gateway, DHCP server, DNS servers
ipconfig /releaseDrop the DHCP lease
ipconfig /renewRequest a new lease
ipconfig /flushdnsClears the resolver cache
ping <host>Reply time, TTL, truncated (TTL=128 indicates ICMP unavailable)
tracert <host>Which hop stops responding
nslookup <name>Which server answered, and what it said
arp -aIP → MAC mappings
route printDefault gateway and routing table
Test-NetConnection <host> -Port <n> # Read TcpTestSucceeded
Test-NetConnection <host> -InformationLevel Detailed
Resolve-DnsName <name>
Resolve-DnsName -Type SRV _ldap._tcp.dc01.corp.local

Windows — ports and processes​

CommandPurpose
netstat -anoConnections, listening ports, owning PID
netstat -ano | findstr :445One port
netstat -ano | findstr LISTENINGListening sockets only
netstat -eInterface errors and discards
tasklist /FI "PID eq 4128"Which process owns that socket
taskkill /PID 4128 /FTerminate it
Get-NetTCPConnection -LocalPort 445 |
Select-Object LocalAddress, State, OwningProcess,
@{n='Process';e={(Get-Process -Id $_.OwningProcess).ProcessName}}

Windows — Active Directory​

CommandPurpose
net user <name>Locked, disabled, expired?
net user <name> /active:yesUnlock or enable
net user <name> *Reset the password
nltest /dsgetdc:corp.localCan this machine see a DC?
dsquery user -limit 5Query AD
klistCached Kerberos tickets
klist /purgeClear them
w32tm /resyncForce time sync
gpupdate /forceRe-apply Group Policy
gpresult /rWhich policies applied, and why
whoami /allYour token: groups, privileges, logon type
Get-ADUser -Identity "ravi" -Properties LockedOut, Enabled, PasswordExpired
Get-ADGroupMember -Identity "IT Support"
Get-ADComputer -Filter * -Properties * | Where-Object {$_.OperatingSystem -like "*Server*"}
Test-ADComputer -ComputerName "SRV01" -Server "dc01.corp.local"

Windows — services and system​

CommandPurpose
Get-ServiceState and start type
Get-Service | ? Status -ne 'Running'What is not running
systeminfoOS version, boot time, patch
Get-PhysicalDiskDisk health
Get-VolumeFree space
Get-HotFixPatching state
perfmon /relReliability Monitor
sfc /scannowRepair protected files
DISM /Online /Cleanup-Image /RestoreHealthRepair component store

Windows — events​

Get-WinEvent -FilterHashtable @{
LogName = 'System'; Level = 1,2; StartTime = (Get-Date).AddHours(-1)
} | Select-Object TimeCreated, Id, ProviderName, Message

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625} -MaxEvents 10
IDSourceMeans
7DiskBad block
51DiskI/O error
55NtfsFile system corruption
41Kernel-PowerUnexpected shutdown
4624 / 4625SecurityLogon success / failure
1058SCMService disabled
7031SCMService crashed

Windows — printers​

CommandPurpose
Get-PrinterQueues, ports, status
Get-PrintJob -PrinterName "HP"The queue, with errors
Get-PrintServerPrint servers
Get-Service SpoolerThe critical service
Get-PrinterPortPort type and host address

Windows — virtualisation​

CommandPurpose
Get-VMAll VMs and state
Get-VMSnapshot -VMName XCheck for stale snapshots
Get-VMNetworkAdapter -VMName XWhich vSwitch
Get-VMHostHost capacity
Get-VMIntegrationService -VMName XIntegration services

Linux equivalents​

PurposeCommand
Interfacesip a / ip addr
Routing tableip r / ip route
ARP / neighboursip neigh
Socketsss -tulpn
Port testnc -zv <host> <port>
DNSdig +short <name> / dig -x <ip>
Resolver configresolvectl status
Service statussystemctl status <unit>
Service logsjournalctl -u <unit> -n 50
Disk spacedf -h
Memoryfree -h
Loaduptime
Processestop / htop
Path tracetraceroute <host>
Firewallufw status / iptables -L -n

PowerShell essentials​

# Pipeline
Get-Service | Where-Object {$_.Status -eq 'Running'} | Measure-Object

# Objects, not strings
Get-Process | Select-Object -First 5 Name, Id, CPU
Get-Service | Select-Object Name, @{n='State'; e={$_.Status}}

# Export for a ticket
Get-ADUser -Filter * | Select-Object Name, Enabled |
Export-Csv C:\temp\users.csv

# Write a useful log entry
Write-EventLog -LogName Application -Source "Support" `
-EventId 4000 -EntryType Information -Message "Reset password for ravi"
Verb-Noun matters

Get, Set, New, Remove, Start, Stop, Restart, Enable, Disable, Test, Enter, Exit, Invoke, Register, Unregister, Wait, Resize, Search, Trace. Interviewers hear "knows the cmdlet conventions" and score it.

Was this page helpful?