1

How can I access all parameters in PowerShell like in bash with $* ?

2
  • 1
    Do you mean $args variable? Commented Dec 7, 2013 at 18:34
  • yeah i need all of them :D args[0] args[1]... if its possible i need them in one expression like $* in bash Commented Dec 7, 2013 at 18:37

3 Answers 3

3

There are a few ways to do this:

  • $args will have arguments, but only if they script doesn't have any named arguments. If it does, $args will be blank.
  • $psBoundParameters will have the bound parameters for the current function. This will show you the values provided for a script file or function, but it won't show you a default value.
  • If you're dealing with Pipelined input, $_ and $input will contain the input from the pipeline.

The way you've written the question, it also makes me wonder if you're trying to get all variables defined. If this is what you're after, you'd use Get-Variable.

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

Comments

2

It can be accessed as an array. E.g. $args[0] $args[1] ... size is $args.length

Comments

2

To see them all, try

$args | Out-string

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.