Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| powershell_script_arguments [2021/10/22 14:25] – created mgupton | powershell_script_arguments [2021/11/01 11:58] (current) – mgupton | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Powershell Script Arguments ====== | + | ====== Powershell Script Arguments/ |
| + | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | |||
| + | |||
| + | <code powershell> | ||
| + | function foo { | ||
| + | param( | ||
| + | [Parameter(Mandatory=$true)] | ||
| + | [Parameter(Mandatory=$true)] | ||
| + | ) | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | === switch parameters === | ||
| + | |||
| + | <code powershell> | ||
| + | function Switch-Item { | ||
| + | param ([switch]$on) | ||
| + | if ($on) { " | ||
| + | else { " | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | === positional arguments === | ||
| + | |||
| + | <code powershell> | ||
| + | function Get-Extension { | ||
| + | $name = $args[0] + " | ||
| + | $name | ||
| + | } | ||
| + | </ | ||