PowerShell Practice Exercises: 10 Tasks to Try Yourself
Reading about cmdlets only gets you so far. These ten tasks are small enough to finish in a few minutes each. Try them in any PowerShell window before you look up the answer.
Files and folders
1. List every .txt file in a folder, including subfolders.
2. Create a folder called reports and put three empty files in it.
3. Copy that folder to a new name, then delete the original.
Get-ChildItem -Recurse -Filter *.txt
Filtering and sorting
4. Show the five biggest files in a folder.
5. List only the services that are currently running.
6. Find processes using more than 100 MB of memory.
Get-Service | Where-Object Status -eq Running
Text and data
7. Count how many lines in a log file contain the word error.
8. Split a comma separated string into an array and print the third item.
9. Build a hash table of three names and ages, then look one up.
10. Export a list of running processes to a CSV file.
Select-String -Path app.log -Pattern 'error' | Measure-Object
Want checking as you go?
shellreps turns exercises like these into labs with hidden flags, so you know when you got it right instead of guessing. The first lab is free and needs no signup.
Practice it for real. shellreps has hands-on PowerShell labs that run in your browser, no install. The first one is free, no signup. The terminal mimics PowerShell syntax so the habits carry over, though it isn't Microsoft's PowerShell itself.