PowerShell Split string into variables

Viewed 17913

I have a line a text and I want the first word to be a variable, the second to be a second but all the rest to be consider one single var.

For example splitting Mary had a little lamb would result in:

  • $var[1] = Mary
  • $var[2] = had
  • $var[4] = a little lamb

How can I achieve this when I split by space?

3 Answers
Related