Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Powershell Script Arguments/Parameters ====== * [[https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_functions_advanced_parameters?view=powershell-7.1]] * [[https://www.red-gate.com/simple-talk/sysadmin/powershell/how-to-use-parameters-in-powershell/]] <code powershell> function foo { param( [Parameter(Mandatory=$true)] [String]$EmailTo = "ToAddr@gmail.com", [Parameter(Mandatory=$true)] [String]$EmailFrom = "FromAddr@gmail.com" ) } </code> === switch parameters === <code powershell> function Switch-Item { param ([switch]$on) if ($on) { "Switch on" } else { "Switch off" } } </code> === positional arguments === <code powershell> function Get-Extension { $name = $args[0] + ".txt" $name } </code> powershell_script_arguments.txt Last modified: 2021/11/01 11:58by mgupton