PowerShell - Function

By xngo on January 5, 2020

# Define function to add values $a and $b.
    Function add($a, $b)
        return $a+$b
# Use the function. Add 3 and 4 and assign to $sum variable.
    $sum = add 3 4
# Display result to screen.
    Write-Host $sum

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.