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: Maintain Linux Services via SSH Remoting

Version 2: # maintainLinuxServices.ps1 # Version 0.0.2 # Description: this is a simple script to…

Installing Team Foundation Server

1. Installationa. All in oneb. Separate TFS and database (advanced) 2. Setup reportinga. Warehouse databaseb.…

Methods to Embed JavaScript Codes into WordPress

Insert Headers and Footers Plugin - automatically apply script site wide Shortcoder Plugin - make…