🔧 PowerShell Functions Cheat Sheet
Functions let you group code you want to reuse — super handy for modular scripts.
📚 Basic Examples
# Define a simple function function Greet { param([string]$name) Write-Output "Hello, $name!" } # Call the function Greet -name "Alex" # Function with return function Add-Numbers { param($a, $b) return $a + $b } $result = Add-Numbers 5 7 Write-Output "Sum is $result"
📝 Try Your Own Functions
▶️ Run Simulation
Function output will appear here...
💡 Pro Tip: Use
param()
to define function parameters and
return
to output values.