🎓 A1Learner
🔍
0 of 47 lessons completed

PowerShell Intermediate Introduction

PowerShell Intermediate is the step from running single commands to building reusable tools. It turns commands you already know into functions, modules, and scripts that handle errors and run on their own.

A function you already know

A beginner function takes values and returns a result.

function Add-Numbers {
    param([int]$a, [int]$b)
    $a + $b
}
Add-Numbers -a 3 -b 4

The pipeline filters a list

The pipeline sends each number through a filter, and only the even ones survive.

(1..5 | Where-Object { $_ % 2 -eq 0 }) -join ", "

A file holds a result

A script can save its result in a file and read it back later.

Set-Content -Path "note.txt" -Value "done"
Get-Content -Path "note.txt"

Example

function Get-Doubled {
    param([int]$n)
    $n * 2
}
$doubled = foreach ($x in 1..5) {
    Get-Doubled -n $x
}
($doubled | Where-Object { $_ -gt 4 }) -join ", "

Key points

  • Reusable tools: scripts and functions you can run again instead of typing the same commands each time.
  • Advanced functions: functions with stricter rules for their inputs, so bad input is caught early.
  • Modules: collections of functions kept in files you can load when you need them.
  • Error handling: planned responses when a command fails, instead of a raw error stopping everything.
  • Automation: scripts that do repeated work on their own, on a schedule or on demand.

In this example, a function doubles one number. A loop doubles each number from 1 to 5, and the pipeline keeps only results greater than 4, joined into one line.

Note

Everything here builds on the Beginner course, so no beginner idea is taught again.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What does this course build on top of single commands?