Make your computer do the hard work for you.
PowerShell is a typing tool. Instead of clicking through menus to fix a computer, you type one line of text, and the computer does exactly what you say. It saves time and stops mistakes.
Clicking vs. Typing
The Slow Way (Clicking)
- 1. Open the Start Menu
- 2. Search for "Control Panel"
- 3. Click "Network Settings"
- 4. Click "Adapter Options"
- 5. Find your IP address
The Fast Way (PowerShell)
Just type this and hit Enter:
Done in 2 seconds.
How to speak the language
PowerShell uses a very simple naming rule. Every action is built like a tiny sentence. We call these commands Cmdlets (pronounced "Command-Lets"). They always follow the rule: Action - Thing.
Smart Blocks, Not Just Words
Old computer systems just spit out lines of text. PowerShell is smarter. It gives you "Objects." An object is like a smart box that holds many facts inside it.
Dumb Text
It just looks like the word "Apple". You can only read it.
Smart Object
It is a box labeled "Apple" that knows its own facts.
The Pipeline: Passing the Baton
Because PowerShell uses smart boxes (objects), you can pass a box from one command to the next using a
straight line called a Pipeline ( | ).
Variables: Saving Things for Later
Sometimes you want to save an answer so you can use it again in five minutes. In PowerShell, you
put a dollar sign ($) in front of a word to create a saving box, called a
Variable.
- The
$tells the computer: "Hey, remember this." - You can save a word, a number, or a whole smart object.
- You can name it almost anything you want.
Scripts: Doing Many Things at Once
If you have to type the same five commands every morning, you will get bored. Instead, you can save those five commands into a text file. This file is called a Script.
The Automation Goal
You double-click the script file. The computer runs all five commands instantly. You go drink coffee while the computer does your morning work for you.
PowerShell scripts usually end with .ps1 (Example: SetupComputer.ps1)
It Works Everywhere Now
A long time ago, PowerShell only worked on Microsoft Windows. Not anymore. Microsoft made it open to the world. Now you can use the exact same skills on almost any computer.
Windows
It comes built-in. It is the boss of Windows.
Mac
You can download it and manage your Apple files easily.
Linux
Servers run it to automate big web systems.
3 Easy Things You Can Try Today
1. See what is slowing down your PC
Find out what programs are using the most memory.
2. List all files in a folder
See exactly what is inside your documents folder.
3. Check exactly how long your PC has been on
Find the exact start time of your computer.
Shortcuts for Fast Typers
Typing Get-ChildItem every time you want to see your files gets annoying. PowerShell has
built-in nicknames for long commands. These are called Aliases.
Finding the Needle in the Haystack
If you ask for a list of computer parts, you might get 1,000 items. To only see the ones you care
about, we use a filter called Where-Object.
Making the Answers Look Good
Sometimes the computer spits out too much data. You can force PowerShell to organize the smart objects into a clean table or a simple list.
Format-Table
Lines up the facts in neat columns.
Format-List
Shows one item at a time, listing every fact top to bottom.
Instant Reports for Your Boss
You gathered all this data, now you need to put it in an Excel file. Instead of copy-pasting, just add
one more pipe to the end of your command: Export-Csv.
Modules: Adding New Tools
PowerShell comes with basic tools. But what if you want to manage Amazon Web Services, or Microsoft Teams? You just download a new box of tools. These boxes are called Modules.
The "Do It 100 Times" Button
If you have to rename 100 files, do not do it by hand. Use a loop. The
ForEach-Object command takes a list of things and performs the exact same action on
every single one of them.
Computers never get tired. Let them do the boring repetition.
The Safety Switch (-WhatIf)
Before you hit Enter on a command that deletes files or shuts down servers, you might feel scared. What
if you made a typo? Just add -WhatIf to the end.
* The computer didn't actually turn off. It just told you what WOULD happen.
Why is my script blocked?
You wrote your first script, double-clicked it, and got a big red error saying it is "disabled." Don't panic. Windows has a built-in security guard called the Execution Policy to stop bad viruses from running silently.
Restricted (Default)
The guard says: "No scripts allowed at all. You can only type commands one by one."
RemoteSigned
The guard says: "You can run your own scripts, but scripts from the internet need a digital signature."
Set-ExecutionPolicy RemoteSigned
Fixing Computers from your Couch
If someone in the other building has a broken computer, you don't need to walk over there. You can use PowerShell Remoting to secretly connect to their computer in the background without interrupting their work.
Enter-PSSession -ComputerName "Reception-PC"
# 2. Your black screen now controls their PC!
[Reception-PC]: Restart-Service PrinterSpooler
Your Personal Setup (Profiles)
A Profile is simply a script that runs automatically every single time you open PowerShell.
If you always want your background to be red, or if you always want to load your favorite shortcuts, you put those instructions in your Profile file. It sets up your desk exactly how you like it before you even start working.
$PROFILE and
press enter to see exactly where your personal setup file lives on your hard drive.
Custom Look
Make it yours. Change colors, text sizes, and starting folders automatically.
Don't know what to do? Just ask.
PowerShell comes with a massive built-in instruction manual. If you ever forget how a command works, you
don't even need to use the internet. Just ask PowerShell directly using Get-Help.