Copy · paste · run
PowerShell one-liners you can actually paste.
Ready-to-run PowerShell for the Windows admin tasks you actually do — services
and processes, AD accounts, event logs, large files, network and firewall — each with what it does,
when you need admin, and how to export the result.
15 recipes
- System Find Top CPU / Memory Processes with PowerShell (and Kill One) List the processes using the most CPU or RAM with PowerShell, show memory in MB, and stop a process by name or PID. Copy-paste.
- System List, Start, Stop & Restart Windows Services with PowerShell Find services, see what's running or stopped, restart one, and set startup type — with PowerShell. Copy-paste (some need admin).
- System Get System Info with PowerShell (OS, CPU, RAM, Serial, Uptime) Pull OS version, CPU, total RAM, BIOS serial and uptime with PowerShell using Get-CimInstance. Copy-paste.
- Users & AD Find Locked-Out Active Directory Accounts with PowerShell List locked-out AD accounts with Search-ADAccount, see recent lockouts, and unlock an account. Needs the RSAT ActiveDirectory module. Copy-paste.
- Users & AD List AD Users by Password Expiry Date with PowerShell Show when each Active Directory user's password expires, find passwords expiring soon, and list never-expires accounts. Needs the ActiveDirectory module. Copy-paste.
- Users & AD List & Manage Local Users and Groups with PowerShell List local users, see who's in Administrators, create a user, and add it to a group with the Microsoft.PowerShell.LocalAccounts cmdlets. Copy-paste (admin).
- Files Bulk Rename Files with PowerShell Rename many files at once with PowerShell — change extensions, add a prefix, replace text, and number files sequentially. Copy-paste.
- Files Find the Largest Files in a Folder with PowerShell List the biggest files under a path with PowerShell, show sizes in MB/GB, and find old or specific-type files to clean up. Copy-paste.
- Files Search File Contents Recursively with PowerShell (grep) Use Select-String to grep file contents recursively, show line numbers, match with regex, and list only matching filenames. Copy-paste.
- Network List & Add Windows Firewall Rules with PowerShell Query Windows Firewall rules, find what's allowed on a port, add an inbound allow rule, and enable/disable rules. Copy-paste (admin).
- Network IP Config, Test-Connection & Open Ports with PowerShell Show IP addresses, test connectivity and a TCP port, list listening ports, and flush DNS with modern PowerShell net cmdlets. Copy-paste.
- Event logs Query the Windows Event Log with PowerShell (Get-WinEvent) Read the Windows event log fast with Get-WinEvent and FilterHashtable — by log, level, event ID and time range. Copy-paste.
- Event logs Find Failed Logons with PowerShell (Security Event 4625) List failed logon attempts from the Security log with Get-WinEvent, extract the account and source IP, and count attempts by user. Copy-paste (admin).
- Output & export Export PowerShell Output to CSV (and Format a Table) Save any PowerShell output to CSV, plain text or JSON, and format clean on-screen tables with Format-Table and calculated columns. Copy-paste.
- Output & export List Installed Software with PowerShell (and Export to CSV) List installed programs fast by reading the Uninstall registry keys (not the slow Win32_Product), find one app, and export to CSV. Copy-paste.
Why this exists
You know the cmdlet exists. You don't remember the exact pipeline.
PowerShell can do almost anything on a Windows box, but the exact Where-Object /
Select-Object / calculated-property pipeline never sticks — so you re-derive it or
paste a half-right snippet. psoneliner.pages.dev is a library of focused,
copy-paste one-liners for real admin tasks, each with a one-line explanation, the elevation it
needs, and the gotchas (slow Win32_Product, RSAT for AD, fast event-log filtering).
How it works
Find the task, copy the line, run it
- Pick a recipe. Browse by area in the full recipe list.
- Copy the one-liner. Every command has a one-click copy button.
- Run it (elevated if noted) and pipe to
Export-Csvif you need the result in a file.
FAQ
Frequently asked questions
Are these PowerShell one-liners free?
Yes. Every recipe on psoneliner.pages.dev is free to read and copy, with no account, paywall, or sign-up. Some outbound links (for example to admin tools) may be affiliate links, which never change the price you pay.
Windows PowerShell 5.1 or PowerShell 7?
Both. These one-liners use cmdlets present in Windows PowerShell 5.1 (built into Windows) and PowerShell 7+. Where a cmdlet or operator only exists in 7+ (like Get-Uptime or the ternary operator), the recipe notes it.
Do I need to run PowerShell as Administrator?
Some do — managing services, reading the Security event log, or changing firewall rules need an elevated prompt. Right-click PowerShell and "Run as administrator" (or run "Start-Process powershell -Verb RunAs"). Each recipe notes when elevation is required.
I get "Get-ADUser is not recognized" — why?
Active Directory cmdlets live in the ActiveDirectory module, part of RSAT (Remote Server Administration Tools). Install it ("Add-WindowsCapability -Online -Name Rsat.ActiveDirectory.DS-LDS.Tools~~~~0.0.1.0") or run the recipe from a domain controller / management box.
Why use the registry for installed software instead of Win32_Product?
Get-CimInstance Win32_Product is slow and can trigger an MSI self-repair on every app it touches. Reading the Uninstall registry keys is fast and safe — that is what the "installed software" recipe uses.
How do I save the output to a file?
Pipe to Export-Csv for a spreadsheet ("... | Export-Csv out.csv -NoTypeInformation"), to Out-File for plain text, or to ConvertTo-Json. The "export" recipe shows each, plus Format-Table for clean on-screen output.