Skip to content

Instantly share code, notes, and snippets.

@bundyfx
Last active November 8, 2015 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bundyfx/b001299b390df28eb11e to your computer and use it in GitHub Desktop.
Save bundyfx/b001299b390df28eb11e to your computer and use it in GitHub Desktop.
param([string]$VMNameStr)
0..(($VMNameStr -split ",").GetLength(0) -1) | % {Set-Variable "VMName$Psitem" -Value ($VMNameStr -split ',')[$Psitem] -PassThru }
#The VMNameStr param is intended to be taken as a single string rather than the conventional array of strings ([String[]]).
#Take values from param, split those and turn it in a range, Foreach of those create a new variable based on the number coming across the pipeline.
#The value of those variables will be the original array split calling the position index of the current item in the pipeline (Passthru to display this on the screen).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment