Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
powershell_script_arguments [2021/10/25 18:01] mguptonpowershell_script_arguments [2021/11/01 11:58] (current) mgupton
Line 1: Line 1:
-====== Powershell Script Arguments ======+====== 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/]]   * [[https://www.red-gate.com/simple-talk/sysadmin/powershell/how-to-use-parameters-in-powershell/]]
  
Line 11: Line 12:
 } }
 </code> </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.1635184882.txt.gz
  • Last modified: 2021/10/25 18:01
  • by mgupton