⚡PowerShellWiki
← All cheat sheets
⚙️

System Administration

Manage processes, services, the registry, and event logs.

Processes

List running processes

Show all processes, sorted by memory use.

Get-Process | Sort-Object WorkingSet -Descending

Find a process by name

Look up a specific process.

Get-Process -Name chrome

Stop a process

Kill a process by name or ID.

Stop-Process -Name notepad -Force

Services

List services

Show all services and their status.

Get-Service | Where-Object Status -eq 'Running'

Start or stop a service

Control a Windows service by name.

Start-Service -Name Spooler
Stop-Service -Name Spooler

Restart a service

Cycle a service off and on.

Restart-Service -Name Spooler

Registry and environment

Read a registry value

Get a value from the Windows registry.

Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName

Read an environment variable

Access an environment variable.

$env:PATH

Set an environment variable (permanent)

Persist a variable for the current user.

[Environment]::SetEnvironmentVariable("MY_VAR", "value", "User")

Event logs and system info

Read recent system errors

Get the 20 most recent error events.

Get-WinEvent -LogName System -MaxEvents 20 | Where-Object LevelDisplayName -eq 'Error'

Get computer info

Show OS and hardware details.

Get-ComputerInfo | Select-Object CsName, OsName, OsVersion, CsTotalPhysicalMemory

Related cheat sheets