0

From this I can see I can do this with range operator:

$myArray = @(4..9)

But how can I do something like this:

$myArray = @(usr4..9)

I have tried various deviations of this with nonsense errors:

$myArray = 4..9 |
%\{ "usr$_"\}
2
  • 1
    What, exactly, would you have as an output? And what's the deal with lorem ipsum anyway? Commented Jun 16, 2015 at 8:34
  • I just want to add usr4, usr5, usr6 to the array. I had to write half an assay to post. no idea why. Commented Jun 16, 2015 at 8:36

1 Answer 1

3

Would that do?

@(4..9) | % {"usr" + $_}
Sign up to request clarification or add additional context in comments.

3 Comments

Precisely. But it seems this prints the users. How do i avoid this?
@user3019059 Simply assign the result to a variable or send it down the pipeline to do whatever you want to do with it.
Side note: @() is not required. 4..9 | % { "usr$_" } will suffice.

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.