Functions are your Friends
get-command -CommandType function
cd function:
dir function: or ls function:
Find variables that change or prompt users for input; move first
Find all hard-coded variables; move second
Work with variables follows
Output final result
Example
$a = 4 $b = 5 $c = $a + $b Write-Host $c
Example + User Input
[int]$a = Read-Host -Prompt "A" [int]$b = Read-Host -Prompt "B" $message = "Your Result:" $c = $a + $b Write-Host $message $c
Convert to 'Basic' Function
function Add([int]$a, [int]$b) { $message = "Your Result:" $c = $a + $b Write-Host $message $c }
But nothing happens!!!
[int]$a = Read-Host -prompt "A" [int]$b = Read-Host -prompt "B" Add $a $b
about_Functions
Build a Better Function
Functions
about_Functions_Advanced
Function Syntax Template
By Ken Maglio
Automation Solution Engineer My License Plate says it all "I-AU2M8"