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
zidsal
  • 577
  • 1
  • 7
  • 30
  • Does putting them in quotes not work? – Carey Gregory Jul 05 '13 at 15:19
  • it would work if they were positional parameters. But each command needs to be on its own line in powershell. – zidsal Jul 05 '13 at 15:25
  • [maybe this can help](http://stackoverflow.com/questions/5460270/quickly-enter-command-line-parameters-for-visual-studio-debugging) –  Jul 08 '13 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 – VRK Jul 10 '13 at 14:57

1 Answers1

1

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"
Oliver Salzburg
  • 21,652
  • 20
  • 93
  • 138