SyahrWorksSyahrWorks
Back to Blog

Tutorial

The Complete Guide to CMD & PowerShell Commands: From Beginner to Administrator

August 5, 202612 min readWindows, CMD, PowerShell, Tutorial
The Complete Guide to CMD & PowerShell Commands: From Beginner to Administrator

This material is written for Windows 10 and Windows 11. All syntax follows modern versions and is presented in standard English.

Table 1: Command Prompt (CMD)

How to open: press Win + R, type cmd, press Enter. For administrative commands, right-click → Run as administrator.

A. Directory Navigation

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
cdChange directorycd [path]cd C:\Users\You\DocumentsUse cd .. to go up one level; cd /d D:\Folder to switch drives in one step.
dirList folder contentsdir [path]dirAdd /w (wide view) or /s (include subfolders).
clsClear the screenclsclsThe most commonly used command to keep the output tidy.
pushd / popdSave & return to a directorypushd [path] then popdpushd D:\Data → ... → popdUseful when moving between folders in a single session.
treeDisplay the folder structuretree [path]tree C:\Users\You\DocumentsUse tree /f to include file names.

B. File & Folder Management

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
md / mkdirCreate a new foldermd [folder name]md Reports2026Can create nested folders: md a\b\c.
rd / rmdirDelete a folderrd [folder]rd /s /q Reports2026/s deletes with contents, /q without confirmation. Be careful!
del / eraseDelete filesdel [file]del *.tmpFiles are not moved to the Recycle Bin. Use wildcards * and ?.
copyCopy filescopy [source] [destination]copy report.docx D:\BackupFor whole folders, use xcopy or robocopy.
xcopyCopy files & foldersxcopy [source] [destination] /e /ixcopy C:\Data D:\Backup /e /i/e includes empty subfolders, /i assumes destination is a folder.
robocopyAdvanced folder copyingrobocopy [source] [destination] [options]robocopy C:\Data D:\Backup /MIRMore reliable than xcopy; /MIR mirrors the source.
moveMove files/foldersmove [source] [destination]move report.docx D:\BackupCan also be used for renaming (see ren).
ren / renameRename files/foldersren [old name] [new name]ren report.docx report-final.docxCannot move between drives.
attribChange file attributesattrib [+/-r/+h/+s] [file]attrib +h data.txt+r read-only, +h hidden, +s system.
typeDisplay the contents of a text filetype [file]type config.txtFor long files use more.
moreDisplay file contents one screen at a timemore [file]more readme.txtPress Space to continue, Q to quit.
fcCompare two filesfc [file1] [file2]fc version1.txt version2.txtUse fc /b for binary comparison.

C. Searching for Files & Text

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
whereFind the location of a programwhere [program name]where notepadShows the full path to the executable.
findSearch for text within a filefind "text" [file]find "ERROR" server.logCase-sensitive by default.
findstrSearch for text using patternsfindstr [options] "pattern" [file]findstr /i "fail" *.log/i ignores case; supports regex.
dir /s /bSearch for files across all subfoldersdir /s /b [file name]dir /s /b *.pdfThe fastest combination for searching by file name.

D. System Information

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
verDisplay the Windows versionververShows the build version.
systeminfoFull system informationsysteminfosysteminfoRAM, OS, hardware, etc. Takes a few seconds.
hostnameDisplay the computer namehostnamehostnameUseful for automation scripts.
whoamiDisplay the current userwhoamiwhoamiwhoami /all shows full user & group details.
setDisplay all environment variablessetsetset NAME=value to create one temporarily.

E. Network Information & Configuration

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
ipconfigDisplay IP configurationipconfigipconfig /all/all full details; /flushdns clears the DNS cache.
pingTest connectivity to a hostping [host]ping google.comping -t pings continuously (stop with Ctrl+C).
tracertTrace the route of packetstracert [host]tracert google.comShows the hops toward the destination.
pathpingCombination of ping + tracertpathping [host]pathping google.comAnalyzes packet loss per hop; slower.
netstatDisplay network connectionsnetstat -anonetstat -ano-a all connections, -n no DNS, -o process PID.
nslookupLook up DNS informationnslookup [domain]nslookup google.comReturns the IP address of a domain name.
getmacDisplay the MAC addressgetmac /vgetmac /vUseful for device whitelisting.
net useConnect to a network drivenet use [drive]: [path]net use Z: \\server\datanet use Z: /delete to disconnect.
netshAdvanced network configurationnetsh [context] [command]netsh wlan show profilesWi-Fi, firewall, etc. configuration.

F. Process & Program Management

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
tasklistDisplay the list of processestasklisttasklist /svc/svc shows the services running in each process.
taskkillTerminate processestaskkill /PID [number] /Ftaskkill /IM chrome.exe /F/IM by name, /PID by number, /F force.
startRun a program/URLstart [program/url]start notepadstart http://... to open a browser.

G. Service Management

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
net startDisplay/start servicesnet start [name]net start wuauservWith no arguments, lists all running services.
net stopStop a servicenet stop [name]net stop wuauservRequires administrator rights.
scAdvanced service controlsc query [name]sc query | findstr RUNNINGsc config [name] start= auto sets the startup mode.

H. Environment Variables & Disk

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
setxSet a permanent environment variablesetx [NAME] "value"setx JAVA_HOME "C:\Program Files\Java\jdk-17"Applies to new sessions only.
echo %VAR%Display a variable valueecho %PATH%echo %USERNAME%%VAR% is the variable syntax in CMD.
chkdskCheck a diskchkdsk C:chkdsk C: /f/f fixes errors; may require a restart.
diskpartDisk management (partition, format)diskpartlist disklist diskInteractive mode — be careful, it is very dangerous.
wmicSystem information via WMIwmic logicaldisk get name,freespacewmic logicaldisk get size,freespaceBeing deprecated on newer Windows 11; use PowerShell.

I. Users, Shutdown & Utilities

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
net userManage user accountsnet usernet user Andi /addnet user Andi * to set a password interactively.
net localgroupManage local groupsnet localgroup [group]net localgroup AdministratorsAdd a user to a group: net localgroup Administrators Andi /add.
runasRun a program as another userrunas /user:[user] [program]runas /user:Administrator cmdRequires the target user's password.
shutdownShut down / restart the computershutdown /r /t 0shutdown /s /t 60/s shutdown, /r restart, /a abort, /t seconds.
logoffLog out of the current sessionlogofflogoffCloses all applications in the active session.
sfc /scannowRepair system filessfc /scannowsfc /scannowRequires admin; verifies Windows file integrity.
DISMRepair the Windows imageDISM /Online /Cleanup-Image /RestoreHealthDISM /Online /Cleanup-Image /RestoreHealthRun before sfc for severe damage.
gpupdateRefresh group policygpupdate /forcegpupdate /forceApplies policy without restarting.
helpHelp for commandshelp [command]help cdcommand /? also shows help.
exitClose the CMD windowexitexitAlso used to end batch scripts.
titleSet the window titletitle [text]title Server MonitorUseful for telling many CMD windows apart.
date / timeDisplay/set the date & timetimetimeFor scripts, use echo %DATE% %TIME%.
assocDisplay file extension associationsassoc .txtassoc .txtassoc .txt=txtfile to change an association.

Table 2: Windows PowerShell

How to open: right-click Start → Windows PowerShell or Terminal. For administrative commands, choose Run as administrator. Tip: PowerShell understands almost all CMD commands (built-in aliases). This table focuses on native PowerShell cmdlets (the Verb-Noun pattern, e.g. Get-ChildItem).

A. Directory Navigation

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
Get-LocationDisplay the current directoryGet-LocationGet-LocationAliases: pwd, gl.
Set-LocationChange directorySet-Location [path]Set-Location C:\Users\You\DocumentsAliases: cd, sl.
Clear-HostClear the screenClear-HostClear-HostAlias: cls.
Push-Location / Pop-LocationSave & return to a directoryPush-Location [path]Pop-LocationPush-Location D:\Data → ... → Pop-LocationEquivalent to pushd/popd in CMD.
Get-ChildItemList folder contentsGet-ChildItem [path]Get-ChildItem C:\Users\You -RecurseAliases: dir, ls, gci. -Recurse includes subfolders.

B. File & Folder Management

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
New-ItemCreate a file/folderNew-Item -Path [path] -ItemType [type]New-Item -Path Reports2026 -ItemType Directory-ItemType File for an empty file.
Remove-ItemDelete files/foldersRemove-Item [path]Remove-Item Reports2026 -Recurse -ForceAliases: rm, del. -Recurse for folders with contents.
Copy-ItemCopy files/foldersCopy-Item [source] [destination]Copy-Item report.docx D:\BackupAliases: cp, copy. -Recurse for folders.
Move-ItemMove files/foldersMove-Item [source] [destination]Move-Item report.docx D:\BackupAliases: mv, move.
Rename-ItemRename files/foldersRename-Item [path] -NewName [name]Rename-Item report.docx -NewName report-final.docxAliases: ren, rni.
Get-ContentDisplay the contents of a fileGet-Content [path]Get-Content server.log -Tail 50Aliases: cat, type. -Tail 50 last 50 lines.
Set-ContentWrite/overwrite file contentsSet-Content [path] -Value [text]Set-Content config.txt -Value "port=8080"Add-Content to append without overwriting.
Out-FileSave output to a file[command] | Out-File [path]Get-Process | Out-File processes.txtSaves any output as text.
Test-PathCheck whether a path existsTest-Path [path]Test-Path C:\WindowsReturns True/False.
Select-StringSearch for text in filesSelect-String -Path [file] -Pattern [pattern]Select-String -Path *.log -Pattern "ERROR"Alias: sls. A more powerful equivalent of findstr.
Where-ObjectFilter objects by condition[objects] | Where-Object { condition }Get-Process | Where-Object {$_.CPU -gt 100}Aliases: ?, where. A key feature of the PowerShell pipeline.

C. System & Network Information

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
Get-ComputerInfoFull system informationGet-ComputerInfoGet-ComputerInfoRAM, OS, BIOS, etc.
Get-DateDisplay the date & timeGet-DateGet-Date -Format "yyyy-MM-dd"Very useful for naming backup files.
Get-NetIPAddressDisplay IP configurationGet-NetIPAddressGet-NetIPAddress -AddressFamily IPv4The modern equivalent of ipconfig.
Test-ConnectionTest connectivity to a hostTest-Connection [host]Test-Connection google.com -Count 4Alias: ping.
Test-NetConnectionTest connection + portTest-NetConnection [host] -Port [port]Test-NetConnection google.com -Port 443Alias: tnc. Checks connectivity & open ports.
Resolve-DnsNameLook up DNS informationResolve-DnsName [domain]Resolve-DnsName google.comThe modern equivalent of nslookup.
Get-NetTCPConnectionDisplay network connectionsGet-NetTCPConnectionGet-NetTCPConnection -State ListenA more structured equivalent of netstat -ano.
Clear-DnsClientCacheClear the DNS cacheClear-DnsClientCacheClear-DnsClientCacheEquivalent to ipconfig /flushdns.

D. Processes, Services & Disk

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
Get-ProcessDisplay the list of processesGet-ProcessGet-Process chromeAliases: ps, gps.
Stop-ProcessTerminate a processStop-Process -Name [name] -ForceStop-Process -Name chrome -ForceAlias: kill.
Start-ProcessRun a programStart-Process [program]Start-Process notepad-Verb RunAs to run as administrator.
Get-ServiceDisplay the list of servicesGet-ServiceGet-Service | Where-Object {$_.Status -eq "Running"}Alias: gsv.
Start-Service / Stop-ServiceStart/stop servicesStart-Service [name]Restart-Service wuauservRequires admin. Restart-Service combines both.
Get-PSDriveDisplay drives & locationsGet-PSDriveGet-PSDrive -PSProvider FileSystemIncludes network & registry drives.
Get-VolumeDisplay volume/disk informationGet-VolumeGet-VolumeCapacity & free space per drive.
Get-DiskDisplay physical disksGet-DiskGet-DiskInformation about attached physical disks.

E. Users, Environment & Utilities

CommandFunction / Short DescriptionBasic SyntaxExample UsageNotes
Get-LocalUserDisplay local user accountsGet-LocalUserGet-LocalUserModern Windows 10/11.
Get-LocalGroupDisplay local groupsGet-LocalGroupGet-LocalGroup -Name AdministratorsList members: Get-LocalGroupMember -Group "Administrators".
$env:NAMERead an environment variable$env:NAME$env:USERNAMESet permanently: [Environment]::SetEnvironmentVariable("NAME","value","User").
Get-ChildItem Env:Display all environment variablesGet-ChildItem Env:Get-ChildItem Env: | Sort-Object NameEquivalent to set in CMD.
Get-HelpHelp for cmdletsGet-Help [cmdlet]Get-Help Get-Process -FullAlias: help. Try Update-Help for the full version.
Get-CommandFind available cmdlets/aliasesGet-Command [word]Get-Command *service*Lists every command matching the pattern.
Get-HistoryCommand history of this sessionGet-HistoryGet-History | Select-Object -Last 10The last 10 commands.
Export-CsvSave output as CSV[objects] | Export-Csv [path]Get-Process | Export-Csv processes.csvCan be opened in Excel.
ConvertTo-JsonConvert output to JSON[objects] | ConvertTo-JsonGet-Service | ConvertTo-JsonUseful for API integration.
Invoke-RestMethodCall a REST APIInvoke-RestMethod -Uri [url]Invoke-RestMethod -Uri https://api.github.com/users/rohmansyah23Alias: irm. Test/fetch data from APIs.
Restart-Computer / Stop-ComputerRestart / shut down the computerRestart-Computer -ForceRestart-Computer -ForceEquivalent to shutdown /r but more PowerShell-native.
Get-EventLog / Get-WinEventRead Windows logsGet-WinEvent -LogName System -MaxEvents 20Get-WinEvent -LogName Application -MaxEvents 10Log-based troubleshooting.
Set-ExecutionPolicySet the script execution policySet-ExecutionPolicy RemoteSignedSet-ExecutionPolicy -Scope CurrentUser RemoteSignedRequired before running .ps1 files.
Compress-Archive / Expand-ArchiveZip / unzip filesCompress-Archive [source] -DestinationPath [zip]Compress-Archive *.log -DestinationPath logs.zipBuilt-in zip without extra applications.

Differences Between CMD and PowerShell

AspectCommand Prompt (CMD)Windows PowerShell
ParadigmText-based command interpreter (DOS legacy)Object-oriented shell & scripting language based on .NET
OutputPure text (strings)Objects (with properties & methods)
PipelinePasses text between commandsPasses objects between cmdlets (|)
Scripting supportSimple batch (.bat/.cmd)Full scripting (.ps1) — functions, classes, modules, error handling
Variables%NAME%$NAME, objects, arrays, hash tables
Number of commandsLimited (a few dozen)Thousands of cmdlets + full access to .NET & WMI/CIM
Enrichment featuresMinimalAutomatic formatting, Export-Csv, ConvertTo-Json, remoting (WinRM)
Script securityNo restrictionsExecutionPolicy restricts running .ps1
Use casesQuick tasks & simple scripts, legacy batch compatibilityModern administration, automation, large-scale system management
RecommendationStill useful, but no longer evolvingThe standard for modern Windows administration — all new learning material points here

In short: CMD is a text typewriter — what you see is plain text. PowerShell is an object engine — every output can be filtered, sorted, and processed further, making it far more flexible for administration and automation.


Learning Recommendations

The order of commands recommended for beginners, from the most basic to advanced:

Stage 1 — Foundations (Days 1–3)

  1. Navigation: cd / dirSet-Location / Get-ChildItem
  2. Clearing the screen: clsClear-Host
  3. Creating folders: mdNew-Item -ItemType Directory
  4. Viewing file contents: typeGet-Content

Stage 2 — File Management (Week 1)

  1. Copying: copy / xcopyCopy-Item
  2. Moving & renaming: move / renMove-Item / Rename-Item
  3. Deleting: del / rdRemove-Item -Recurse -Force
  4. Searching files & text: findstr / whereSelect-String / Where-Object

Stage 3 — System & Network (Week 2)

  1. System information: systeminfo / hostname / whoamiGet-ComputerInfo
  2. Basic networking: ipconfig / ping / nslookupGet-NetIPAddress / Test-Connection / Resolve-DnsName
  3. Active connections: netstat -anoGet-NetTCPConnection

Stage 4 — Administration (Weeks 3–4)

  1. Processes: tasklist / taskkillGet-Process / Stop-Process
  2. Services: net start / scGet-Service / Restart-Service
  3. Environment variables: set / setx$env:NAME
  4. Troubleshooting: sfc /scannow / DISMGet-WinEvent / Test-NetConnection

Stage 5 — Automation (Month 1+)

  1. Pipeline & filtering: Where-Object / Select-Object / Sort-Object
  2. Your first script: save commands to a .ps1 file, set the ExecutionPolicy
  3. Output to file: Out-File / Export-Csv / ConvertTo-Json
  4. API & integration: Invoke-RestMethod
  5. Functions & modules: create your own functions for repetitive tasks

Practical advice: learn the commands in both CMD and PowerShell at the same time — because they complement each other, and many CMD commands are still used in modern scripts for compatibility. Start with PowerShell as your main target because it is the standard for Windows administration today.

Written by Muhammad Rohman Syah