Reputation: 12876
Using Powershell I'd like to call my script as follows:
myscript.ps1 -device1 enable -device2 disable -device3 enable
Each device
paramenter is defined as String
followed by a bool
value.
param(
[string] $device1,
[string] $device2,
[string] $device3
)
Does PowerShell support this with some predefined functions or parameters or would you implement this in a totally different way? I'd like to avoid a parsing for enable
and disable
.
Upvotes: 2
Views: 484
Reputation: 58931
I would implement this using a switch
:
param(
[switch] $device1,
[switch] $device2,
[switch] $device3
)
So you can invoke your script using:
myscript.ps1 -device1 -device3
Upvotes: 4