I know how to run scripts with parameters like script.ps1 -arcive=true
but I'm trying to run my script with parameters like script.ps1 -archive
. is that possible?
You are looking for a switch. Its the same concept as a parameter because it is a parameter.
param (
[string] $randomParameter,
[switch] $archive = $false
)
$archive will be false unless you call: script.ps1 -archive
, then it will be true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.