Roi Shidlovsky
Roi Shidlovsky

Reputation: 59

running PS script with arguments

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

Answers (1)

Uuuuuumm
Uuuuuumm

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

Related Questions