Using a series of numbers to loop through an object or process.

I wanted to share this to help people that have to build scripts that parse/writes tons of files.

I always use the numbers depending on scale like the following.

1..17 | |foreach-object {Write-Output "User$_"}

another example if you need files:

$objectarray=@()

1..17 | |foreach-object {new-object psobject  -property @{ name="User$_"}


Well depending on the task you can create a dev variable of sorts. to contain your creation of variables is sound and effective.

I wouldn’t rely on it in a production script unless you did a “foreach($this in $that)” scenario.

chime in if you have any questions or request. I welcome a challenge.

Published by Xajuan Smith

Computer Information Specialist, with a desire to make the masses feel what I was born to channel...The emotion that strives us to do more, speak more boldly and with most sincere ideals that will make life easier and will not hinder the dreams we all have at any given time.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: