0

I'm by no means a Powershell expert, so there may be some misuse of terms:

I'm editing a script to install pieces of software based upon the value of a variable. I want to permit multiple strings so what gets installed can be cherry-picked. Examples:

installsoftware.ps1 -DeployModules "Base, Pack1, Pack3"
installsoftware.ps1 -DeployModules "All"

How would people suggest I accomplish this? Thanks

1 Answer 1

2

I'd so something like this:

param ([string[]]$DeployModules)

Switch -Regex ($DeployModules)
{
  'Base|All'
   { 
     'deploy Base module'
   }

  'Pack1|All'
   {
     'deploy Pack1 module'
   }

  'Pack3|All'
   {
     'deploy Pack3 module'
   }
 }
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.