0

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?

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.