Key PowerShell cmdlets for Windows administration: files, processes, services, networking, and Active Directory basics — with practical examples. Built for Windows admins and certification study. More free study resources at bytebarhq.com.
|
Every cmdlet is Verb-Noun
|
Get-Process, Stop-Service, New-Item |
ls / dir |
Get-ChildItem |
cat |
Get-Content |
echo |
Write-Output |
ps |
Get-Process |
kill |
Stop-Process |
cp |
Copy-Item |
mv |
Move-Item |
rm |
Remove-Item |
man |
Get-Help |
? |
Where-Object |
% |
ForEach-Object |
Get-ChildItem -Recurse -Filter *.log |
find files
|
Get-Content log.txt -Tail 20 -Wait |
live tail
|
Copy-Item src dst -Recurse |
copy folders
|
Get-Help Get-Process -Examples |
built-in examples
|
Get-Command service |
discover cmdlets
|
Get-Help and Get-Command are your built-in documentation.
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5 |
top 5 CPU hogs
|
Stop-Process -Name notepad -Force |
kill a process
|
Get-Service | Where-Object {$_.Status -eq 'Running'} |
running services
|
Restart-Service -Name Spooler |
restart a service
|
| passes objects, not text.
Test-Connection 8.8.8.8 -Count 4 |
ping
|
Test-NetConnection example.com -Port 443 |
port check
|
Get-NetIPAddress |
IP config
|
Get-DnsClientCache | Clear-DnsClientCache |
flush DNS
|
Resolve-DnsName example.com |
nslookup equivalent
|
Test-NetConnection covers ping, port checks, and traceroute in one cmdlet.
Get-ADUser -Filter * -SearchBase "OU=Sales,DC=corp,DC=local" |
all users in an OU
|
Get-ADUser jdoe | Unlock-ADAccount |
unlock an account
|
Set-ADAccountPassword jdoe -Reset |
force a password reset
|
Get-ADComputer -Filter * | Select-Object Name,OperatingSystem |
inventory computers
|
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5 Name |
top 5 CPU hogs, names only
|
Get-ChildItem C:\ -Recurse -ErrorAction SilentlyContinue | Where-Object {$_.Length -gt 100MB} | Sort-Object Length -Descending |
find large files
|
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser |
unblock scripts
|
|
Cmdlets output objects, not text
|
pipe freely
|
$_ |
current object in the pipeline
|
Get-Member to see what's inside.
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.