So I was helping a coworker debug a deployment script at like 11pm and he's sitting there typing commands into the old Command Prompt, copying output into Notepad, and manually searching through it. I just stared at him for a second. Dude, PowerShell has been sitting right there this whole time.
That night kind of stuck with me, because honestly I was the same guy five years ago. PowerShell looks intimidating when you're not used to it — the syntax feels alien, the error messages are verbose, and if you've ever hit an execution policy wall on a fresh machine, you know the specific frustration I'm talking about. But once it clicks? You won't go back.
Here's a collection of PowerShell tips and tricks that I actually use day-to-day. Not a textbook dump — just the stuff that's genuinely made my life easier.
First Things First: Fix Your Execution Policy
This is the thing that blocks literally everyone when they first start writing scripts. You write a .ps1 file, try to run it, and PowerShell just refuses. The fix is one line, but you need to know what you're actually doing here.
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
RemoteSigned means locally created scripts run fine, but anything downloaded from the internet needs a digital signature. That's a reasonable middle ground — you're not going full unrestricted (please don't) and you're not locked out of your own scripts. The -Scope CurrentUser part means you don't even need admin rights to set it. I've seen people set this machine-wide unnecessarily and then wonder why it broke on a shared server.
The Alias System Is Your Friend (Until It Isn't)
PowerShell has aliases built in that map old CMD commands to PowerShell equivalents. So ls, dir, cd — they all work. Great for muscle memory.
But here's the thing though — if you're writing scripts that other people will run, never use aliases. They can be overridden, they're not consistent across platforms (especially now that PowerShell 7 runs on Linux and Mac), and they're a nightmare to read six months later.
# See all available aliases
Get-Alias
# Find what a specific alias maps to
Get-Alias ls
Use full cmdlet names in scripts. Use aliases in your terminal when you're just messing around. That's the rule.
Pipeline Magic: Stop Writing Temp Files
The PowerShell pipeline passes actual objects, not just text strings like Bash does. This is the thing that makes it genuinely powerful and also the thing that confuses people coming from Linux.
Get-Process | Where-Object { $_.CPU -gt 100 } | Sort-Object CPU -Descending | Select-Object -First 10
That one-liner finds your top 10 most CPU-hungry processes. No temp files, no grep, no awk. Each step gets real objects with properties you can filter and sort. I use variations of this constantly when a server starts acting weird and I need to find the culprit fast.
Environment Variables: Setting Them the Right Way
This trips up a lot of people. There are two different ways to set environment variables in PowerShell, and they behave completely differently.
# Temporary — only lasts for this session
$env:MY_VAR = "hello"
# Permanent — persists after reboot (user level)
[System.Environment]::SetEnvironmentVariable("MY_VAR", "hello", "User")
# Permanent — machine level (needs admin)
[System.Environment]::SetEnvironmentVariable("MY_VAR", "hello", "Machine")
I've seen people wonder why their API keys disappear every time they close the terminal. It's because they used the first method. Bookmark the second one. Worth noting — after setting a machine-level variable, you need to restart your terminal (or sometimes your entire session) before it shows up in $env:.
Insider Trick #1: $PROFILE Is Your .bashrc
If you're coming from Linux/Mac, you probably have a .bashrc or .zshrc with all your aliases and functions. PowerShell has the exact same thing — it's called your profile script.
# Find where your profile lives
$PROFILE
# Create it if it doesn't exist
New-Item -ItemType File -Path $PROFILE -Force
# Open it for editing
notepad $PROFILE
Stick your custom aliases, functions, and environment setup in there. Mine has a function that automatically connects to our most-used servers and another that formats JSON output nicely. Anything you're typing repeatedly in your terminal every day should be in your profile.
Insider Trick #2: Out-GridView Is Criminally Underused
Okay this one genuinely surprised me the first time I saw it. Pipe almost anything to Out-GridView and you get an interactive GUI table — sortable, filterable, right there in Windows. No Excel, no copy-pasting.
Get-Service | Out-GridView
Get-EventLog -LogName System -Newest 500 | Out-GridView
That second one is something I use when digging through Windows event logs. Way faster than clicking through Event Viewer. You can even use it with -PassThru to select items from the grid and pipe them into another command. It's one of those features that sounds gimmicky until you actually use it during an incident at 2am and it saves you twenty minutes.
Quick Debugging: Verbose and What-If
Two flags I always reach for when something's behaving weird or when I'm about to run something I'm not 100% sure about:
# See what a command WOULD do without actually doing it
Remove-Item .\logs\* -WhatIf
# Get extra output about what's happening
Copy-Item .\config.json .\backup\ -Verbose
-WhatIf is honestly one of the best safety nets in PowerShell. Tons of cmdlets support it. Before you run any destructive command on a production box, add -WhatIf first. Just a habit worth building.
One More Thing: Upgrade to PowerShell 7
If you're still on Windows PowerShell 5.1 (the one that ships with Windows), go grab PowerShell 7. It's a completely separate install, it runs side by side, and it's genuinely faster with better error handling and cross-platform support.
winget install Microsoft.PowerShell
That's it. One command. After that you'll have pwsh as your PowerShell 7 executable and the old powershell still works for anything that needs it.
Alright, that's enough to keep you busy for a while. If I had to pick just one thing to start with, it'd be setting up your $PROFILE — once you start putting your own stuff in there, you'll wonder how you lived without it. Hope this saves you some time.
๋๊ธ
๋๊ธ ์ฐ๊ธฐ