Posted On February 7, 2020

PowerShell: Special Parameter datatype [switch]

kimconnect 0 comments
blog.KimConnect.com >> Codes >> PowerShell: Special Parameter datatype [switch]
# Demo of a simple function to turn lights on and off
function setLight{
param(
[switch]$on,
[switch]$off
)
if($on){write-host "Turn lights ON."}
if($off){write-host "Turn lights OFF."}
}

Output:

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

PowerShell: Update Windows Computers

There's a more updated version available. <# Update-Windows-Computers-v0.11.ps1 # # Purpose: trigger Microsoft Updates on…

Bash Shell: Rename Files – Prepend and Append

Pre-pending # Prepend any file that doesn't have the word "/thumbs_" in its full path…

JavaScript: Pomodoro Clock

Demo: Pomodoro Clock HTML Code: <body> <div class="header"> <h1>Pomodoro Timer</h1> <h2>A Free Code Camp Student…
Other project: DragonCoin.com