Search notes:

PowerShell: switch parameter

set-strictMode -version latest

function abc {
   param (
      [switch] $F,
      [string] $T,
      [int   ] $N
   )

   write-host "F = $F, T = $T, N = $N"
}

function xyz {

   param (
      [int   ] $num,
      [switch] $flg,
      [string] $txt
   )

   write-host "flg = $flg, num = $num, txt = $txt"

   abc -F:$flg -T $txt -N $num
}

$xyzParameters = (get-command xyz).parameters

$xyzParameters['num'].Attributes[0].Position  #           0
$xyzParameters['flg'].Attributes[0].Position  # -2147483648
$xyzParameters['txt'].Attributes[0].Position  #           1

xyz -flg 42 hello
xyz      42 hello
xyz      42 hello -flg
Github repository about-PowerShell, path: /language/function/parameter/switch/func-with-switch.ps1

See also

The switch type accelerator refers to the System.Management.Automation.SwitchParameter type.

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1759382442, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/language/statement/function/parameters/switch/index(71): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78