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: Delete Hidden System Volume Information Directory

# Incident:The System Volume Information has been copied over to an SMB share, where such…

Function to Import PortQry (a Systernal Utility)

Update: much adieu about nothing. Run this quick script and ignore the prior jibberish: if…

Install AWS Command Line Interface on Windoze

Obtain AWS Access Key: Log into AWS > click on your User Name > My…
Other project: DragonCoin.com