Reputation: 59
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?
Upvotes: 0
Views: 56
Reputation: 656
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
Upvotes: 1