Introduction
Whether you're a system administrator, developer, or power user, mastering command-line tools is essential for efficient Windows management. This comprehensive guide covers 40 of the most useful PowerShell and Command Prompt commands that will boost your productivity and help you troubleshoot issues like a pro.
File and Directory Management
1. dir / ls
Purpose: List directory contents
dir
ls # PowerShell alias
2. cd
Purpose: Change directory
cd C:\Users\Username\Documents
3. mkdir / md
Purpose: Create a new directory
mkdir NewFolder
4. rmdir / rd
Purpose: Remove a directory
rmdir OldFolder
5. copy / cp
Purpose: Copy files
copy source.txt destination.txt
Copy-Item source.txt destination.txt # PowerShell
6. move / mv
Purpose: Move or rename files
move oldname.txt newname.txt
7. del / rm
Purpose: Delete files
del file.txt
Remove-Item file.txt # PowerShell
8. tree
Purpose: Display directory structure
tree /F
System Information
9. systeminfo
Purpose: Display detailed system information
systeminfo
10. Get-ComputerInfo (PowerShell)
Purpose: Get comprehensive computer information
Get-ComputerInfo
11. hostname
Purpose: Display computer name
hostname
12. ver
Purpose: Display Windows version
ver
13. Get-WmiObject (PowerShell)
Purpose: Query system information via WMI
Get-WmiObject Win32_OperatingSystem
Network Commands
14. ipconfig
Purpose: Display network configuration
ipconfig /all
15. ping
Purpose: Test network connectivity
ping google.com
16. tracert
Purpose: Trace route to destination
tracert google.com
17. nslookup
Purpose: Query DNS information
nslookup google.com
18. netstat
Purpose: Display network statistics and connections
netstat -an
19. arp
Purpose: Display ARP cache
arp -a
20. Test-Connection (PowerShell)
Purpose: Advanced ping functionality
Test-Connection -ComputerName google.com -Count 4
21. Invoke-WebRequest (PowerShell)
Purpose: Download files from web
Invoke-WebRequest -Uri "https://example.com/file.zip" -OutFile "file.zip"
Process Management
22. tasklist
Purpose: List running processes
tasklist
23. taskkill
Purpose: Terminate processes
taskkill /IM notepad.exe /F
24. Get-Process (PowerShell)
Purpose: Get detailed process information
Get-Process | Sort-Object CPU -Descending
25. Stop-Process (PowerShell)
Purpose: Stop processes by ID or name
Stop-Process -Name notepad
Disk Management
26. diskpart
Purpose: Disk partition management tool
diskpart
27. chkdsk
Purpose: Check disk for errors
chkdsk C: /F
28. format
Purpose: Format a drive
format D: /FS:NTFS
29. Get-Disk (PowerShell)
Purpose: Get disk information
Get-Disk
30. Get-Volume (PowerShell)
Purpose: Get volume information
Get-Volume
User and Permission Management
31. net user
Purpose: Manage user accounts
net user username /add
32. whoami
Purpose: Display current user
whoami
33. icacls
Purpose: Display or modify file permissions
icacls C:\folder /grant username:F
34. Get-LocalUser (PowerShell)
Purpose: Get local user accounts
Get-LocalUser
Advanced PowerShell Commands
35. Get-Service
Purpose: List and manage services
Get-Service | Where-Object {$_.Status -eq 'Running'}
36. Get-EventLog
Purpose: Retrieve event log entries
Get-EventLog -LogName System -Newest 10
37. Get-Help
Purpose: Get command help
Get-Help Get-Process -Examples
38. Select-Object
Purpose: Select specific properties
Get-Process | Select-Object Name, CPU, Memory
39. Where-Object
Purpose: Filter objects
Get-Process | Where-Object {$_.CPU -gt 100}
40. Export-Csv / Import-Csv
Purpose: Export and import CSV data
Get-Process | Export-Csv processes.csv
$data = Import-Csv processes.csv
Bonus Tips
Command History
- Press F7 in CMD to see command history
- Use
Get-Historyin PowerShell
Piping Commands
Combine commands using pipes (|):
Get-Process | Sort-Object CPU -Descending | Select-Object -First 10
Running as Administrator
Many commands require elevated privileges. Right-click Command Prompt or PowerShell and select "Run as administrator."
Conclusion
These 40 commands form the foundation of efficient Windows command-line usage. Whether you're automating tasks, troubleshooting issues, or managing systems, these tools will significantly enhance your workflow. Start by mastering the basics, then gradually incorporate more advanced PowerShell cmdlets into your daily routine.
Happy scripting! 🚀
Top comments (0)