PowerShell Tutorial
Estimated time: 30-45 minutes
Learning Objectives
- Launch PowerShell and identify the prompt
- Understand and use basic path notation (
~,./,../) - Use
pwd,ls -n, andcdto navigate the filesystem - Open files in an external editor and run simple commands
Materials
- A computer with PowerShell installed
- Access to a text editor (Notepad, VS Code)
Pre-Requisite Knowledge
- Typing and basic text-editing skills
- Familiarity with file/folder concepts and basic OS navigation
- Basic screen-reading familiarity (if applicable)
What is PowerShell?
PowerShell is a cross-platform command-line shell and scripting language that runs on Windows, Linux, and macOS. It lets you control your computer with text commands instead of a graphical user interface (GUI). In this course we use PowerShell to run CLI tools (like OpenSCAD, slicers, or 3DMake), move files, and automate repetitive tasks.
What we’ll do and why
You’ll use PowerShell to run CLI programs, navigate the filesystem, and manipulate files - tasks that are especially efficient when using a keyboard or a screen reader.
Quick tutorial & core concepts
Paths and navigation
~- home directory.- current directory..- parent directory./- current directory shortcut../- parent directory shortcut- Use Tab to autocomplete files and folders (try typing
~/Dthen press Tab)
Paths typically use \ on Windows and / on Unix-like systems; PowerShell accepts / in most contexts.
Useful commands (examples)
pwd # show current directory
ls -n # list names only (screen-reader friendly)
cd path/to/dir # change directory
whoami # current user
Wildcards
*matches zero or more characters?matches a single character
Use ls -n *.scad to filter by extension, for example.
Common operations
File and folder manipulation
mkdir my-folder # create folder
cp -r src dest # copy (use -r for directories)
mv oldname newname # rename or move
rm file # remove file
ni filename.txt # create new file (New-Item alias)
Input, output, and piping
echo 'hello' | clip # copy to clipboard
command > output.txt # redirect output to file
command > $null # discard/suppress output
Use | to pipe output and > to redirect into files.
Editing and running programs
notepad.exe file.txt # open in Notepad (Windows)
code file.txt # open in VS Code (if in PATH)
& './script.ps1' # call operator to run a script or executable
On Linux/macOS, use ./myapp for local executables where appropriate.
Screen-reader friendly tips
- Prefer
ls -nfor name-only output. - Filter lists with
-af(files) or-ad(directories):ls -n -af ~/Documents. - Redirect very long outputs to a file and open it in an editor.
Error handling and control
- Abort a running command:
Ctrl+C - View history: Up/Down arrows or
Get-History - Clear screen:
clear - If an error is long, read the first few lines for the gist and copy short snippets into an editor to examine.
Environment variables & PATH
Environment variables configure your session. PATH tells the shell where to find executables.
echo $env:PATH
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:/mytools", "Machine")
Setting machine-level environment variables requires Administrator privileges.
Running PowerShell as Administrator
- Press Windows+X and choose Windows PowerShell (Admin).
- If a UAC dialog appears, press Alt+Y to accept.
Running CLI applications and archives
To extract ZIP archives:
Expand-Archive -Path file.zip -DestinationPath folder
Aliases and cross-platform notes
PowerShell provides aliases (ls, cp, mv) mapping to cmdlets (Get-ChildItem, Copy-Item, Move-Item). They make PowerShell feel familiar but can behave differently than native Linux tools. Concepts transfer to WSL, macOS, and Linux, but watch path and permission differences.
Step-by-step Tasks (Hands-on)
- Open PowerShell; listen for the prompt and current path.
- Run
pwdto confirm your location. - Run
ls -nin your home directory and note the output. - Practice
cd Documents,cd ../, andcd ~to move between folders. - Create and open a file:
ni example.txt ; notepad.exe example.txt(orcode example.txt).
Checkpoints
- After step 3 you should be able to state your current directory.
- After step 5 you should be able to create and open a text file from PowerShell.
Quick Quiz (10 questions)
- What command prints your current directory?
- What does
~represent? - How do you list only names with
ls? - How do you go up one directory level?
- How would you open
notes.txtin Notepad from PowerShell? - True or False: The pipe operator
|sends output to a file. - Explain why running commands with elevated privileges (as Administrator) might be necessary.
- What is the difference between running a script with
./script.ps1versus& './script.ps1'? - Describe how you would handle a very long command output when using a screen reader.
- What does the
PATHenvironment variable do, and why is it important when running programs like OpenSCAD?
Extension Problems
- Create a folder
OpenSCAD_Projectsin Documents and verify its contents. - Create three files named
a.scad,b.scad,c.scadand list them with a wildcard. - Save
ls -n ~/Documentsoutput todoc_list.txtand open it. - Try tab-completion in a deeply nested folder and note behavior.
- Capture
pwdoutput into a file and open it:pwd > cwd.txt ; notepad.exe cwd.txt. - Build an automated setup script that creates a complete project directory structure, initializes placeholder files, and generates a README.
- Create a PowerShell cheat sheet for your most-used commands; organize by category (navigation, files, scripting, troubleshooting).
- Write a non-visual tutorial for PowerShell basics; use audio descriptions and keyboard-only navigation as the primary learning method.
- Develop a workflow automation script: combines multiple PowerShell concepts (folders, aliases, piping) to solve a real 3D printing task.
- Create a PowerShell proficiency self-assessment: list all concepts covered, provide test commands for each, and reflect on what you learned.
References
- Microsoft. (2024). Accessibility in PowerShell ISE. https://learn.microsoft.com/powershell/scripting/windows-powershell/ise/accessibility-in-windows-powershell-ise
- Microsoft. (2024). Learn PowerShell scripting language. https://learn.microsoft.com/powershell/scripting/overview
- Microsoft. (2024). Environment variables and PATH configuration. https://learn.microsoft.com/powershell/scripting/learn/shell/using-aliases
Helpful Resources
- Accessibility in PowerShell ISE (Microsoft): https://learn.microsoft.com/powershell/scripting/windows-powershell/ise/accessibility-in-windows-powershell-ise
- Learn PowerShell (Microsoft Docs): https://learn.microsoft.com/powershell/scripting/overview
- Environment Variables & PATH: https://poshcode.gitbook.io/powershell-faq/src/getting-started/environment-variables
- Alias Reference: https://learn.microsoft.com/powershell/scripting/learn/shell/using-aliases