powershell_script_arguments

Powershell Script Arguments/Parameters

function foo {
    param(
        [Parameter(Mandatory=$true)]  [String]$EmailTo   = "ToAddr@gmail.com",
        [Parameter(Mandatory=$true)]  [String]$EmailFrom = "FromAddr@gmail.com"
    )
}

switch parameters

function Switch-Item {
  param ([switch]$on)
  if ($on) { "Switch on" }
  else { "Switch off" }
}

positional arguments

function Get-Extension {
  $name = $args[0] + ".txt"
  $name
}
  • powershell_script_arguments.txt
  • Last modified: 2021/11/01 11:58
  • by mgupton