4

In visual studio 2012 it is possible on the debug-> start options to specify command line arguments. I am working on a powershell cmdlet so I'd like to be able to parse multiple commands into powershell. My arguments looks like this

-noexit -command add-pssnapin Registerv2.0 -command New-Token -command www.google.com

the problem is it is treating -command as 1 long string i.e -command "add-pssnapin Registerv2.0 -command New-Token -command www.google.com" rather then 3 seperae commands. Does anyone know how to change this:

edit the results I am looking for is when I run the project

  1. power shell opens

  2. my snapin is registered

  3. Call the cmdlet new-token

  4. enter in the cmdlet parameters
4
  • Does putting them in quotes not work? Commented Jul 5, 2013 at 15:19
  • it would work if they were positional parameters. But each command needs to be on its own line in powershell. Commented Jul 5, 2013 at 15:25
  • maybe this can help Commented Jul 8, 2013 at 13:31
  • If you are trying to pass parameters from Visual studio then this might help. -> 1. Go to project properties -> 2. Go to Debug -> 3. Seperate commands with white space. i.e. par1=val1 par2=val2 par3=val3 Commented Jul 10, 2013 at 14:57

1 Answer 1

1
+50

If you first want add-pssnapin Registerv2.0 and then New-Token to be called, you should chain them in one command, like so:

-command "add-pssnapin Registerv2.0; New-Token"

If New-Token expects a parameter, you should pass it on the command line directly, instead of trying to simulate user input.

For example, New-Item would expect a list of paths and a type as input, both can also be supplied on the command line as parameters. Like so:

New-Item foo -type directory

So, how you would pass the value www.google.com to New-Token depends on the name of the parameter. But could look like:

-command "add-pssnapin Registerv2.0; New-Token -tokenName www.google.com"
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.