Advertisement

PowerShell Commands That Save You Hours

PowerShell looks intimidating, but once you learn a few commands, it becomes incredibly useful. I use these commands almost daily, and they save me tons of time. You don't need to be a programmer - just copy and paste, and you're good.

Here are the PowerShell commands I use most, with real examples you can use right now.

1. Find Large Files Quickly

Need to find what's taking up space? This finds the 20 largest files in a folder:

Get-ChildItem -Recurse | Sort-Object Length -Descending | Select-Object -First 20 Name, @{Name="Size(MB)";Expression={[math]::Round($_.Length/1MB,2)}}

Run this in any folder to see what's eating your storage. The numbers are in MB, so it's easy to read.

2. See What's Using Your CPU

Computer running slow? See what's actually using resources:

Get-Process | Sort-Object CPU -Descending | Select-Object -First 10 ProcessName, CPU, @{Name="Memory(MB)";Expression={[math]::Round($_.WorkingSet64/1MB,2)}}

Shows your top 10 CPU and memory hogs. If something's using way too much, you found your problem.

3. Find Files by Name

Looking for a file but don't remember where? This searches your entire C: drive:

Get-ChildItem -Path C:\ -Recurse -Filter "filename.*" -ErrorAction SilentlyContinue

Replace "filename" with what you're looking for. The ErrorAction part stops it from complaining about folders you can't access.

4. See All Network Connections

Want to see what's connected to the internet? This shows all active connections:

Get-NetTCPConnection | Select-Object LocalAddress, LocalPort, State, OwningProcess | Sort-Object LocalPort

Useful if you're troubleshooting network issues or wondering what's using your bandwidth.

5. Check Your System Info

Quick way to see your computer's specs:

Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion, TotalPhysicalMemory, CsProcessors

Shows your Windows version, total RAM, and processor info. Handy when you need to know what you're working with.

Advertisement

6. Find Duplicate Files

This finds duplicate files by comparing their hashes:

Get-ChildItem -Recurse | Get-FileHash | Group-Object Hash | Where-Object {$_.Count -gt 1} | ForEach-Object {$_.Group | Select-Object Path}

Run this in a folder to find duplicates. Great for cleaning up storage. Be careful - make sure you actually want to delete duplicates before doing it.

7. See Your Computer's Uptime

How long has your computer been running?

(Get-Date) - (Get-CimInstance Win32_OperatingSystem).LastBootUpTime

Shows days, hours, minutes since last restart. If it's been weeks, maybe restart it.

8. Check Available Memory

See how much RAM is available:

Get-Counter '\Memory\Available MBytes'

If this number is really low (like under 1000 MB), that's why your computer is slow. Close some programs.

9. List All Installed Programs

See everything installed on your computer:

Get-WmiObject -Class Win32_Product | Select-Object Name, Version | Sort-Object Name

Useful for seeing what's installed, especially if you're cleaning up. This can take a while to run, so be patient.

10. Export Results to a File

Want to save command results? Add this to the end of any command:

| Out-File -FilePath "C:\results.txt"

Saves the output to a text file. Useful if you need to review results later or share them with someone.

Tips for Using PowerShell

  • Run as admin when needed: Some commands need administrator rights. Right-click PowerShell and choose "Run as administrator".
  • Copy and paste carefully: These commands are exact. Missing a character or space can break them.
  • Use Tab completion: Start typing a command and press Tab to auto-complete. Saves typing and prevents typos.
  • Read error messages: PowerShell's error messages are actually helpful. Read them - they usually tell you what's wrong.

Pro Tip: You can combine commands with pipes (|). For example, you can search for files, filter results, and export to a file all in one command. Once you get comfortable with basic commands, experiment with combining them.

Common Questions

Is PowerShell safe to use?

Yes, the commands I've listed here are all safe - they just read information or do basic tasks. But be careful with commands you find elsewhere. Some can delete files or change important settings.

Do I need to know programming?

Not really. You can just copy and paste these commands. Once you get comfortable, you can start modifying them for your needs.

What's the difference between PowerShell and CMD?

PowerShell is more powerful and modern. It can do everything CMD can do, plus a lot more. CMD is simpler but more limited. I use PowerShell for most things.

Start Using PowerShell Today

Don't be intimidated. Try a few of these commands and see what they do. Start with the simple ones like checking system info or uptime. Once you're comfortable, you'll find yourself using PowerShell all the time.

Advertisement