Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8088811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:11:48+00:00 2026-06-05T19:11:48+00:00

I am a self-taught, newbie programmer, and I feel like this is a really

  • 0

I am a self-taught, newbie programmer, and I feel like this is a really basic question, the kind I’d be able to answer if I had actually studied computer science 😛 In my searching of the intertrons and StackOverflow I haven’t been able to find the answer I’m looking for. So I hope someone can indulge me.

I have a collection of objects. I want to operate on them five at a time, and then move on to the next five. The context is rebooting a bunch of VMs; I’m being asked to stagger them so that the hosts aren’t slammed with all of the VMs rebooting at once.

I sense that the right path is a for i loop in some capacity, and not foreach. I also feel like it could be a combination of do-until and for i but I can’t sift the answer out of my brain.

I could probably do it by removing objects from the collection, but that feels like the “wrong” way to do this, even if it would work.

I’m doing this with Powershell and PowerCLI, but I feel as though the logic I’m trying to understand is more basic than being dependent on any language, so even if you’re not familiar with Powershell, I’m interested in your answer.

Edit: Based on David’s answer below, the following code seems to be what I’m looking for:

$someLetters = @("a","b","c","d","e","f","g","h","i","j","k")

for($i=0; $i -lt $someLetters.length; $i+=5)
{
    Write-Host ("the letter is " + $someLetters[$i] + " and i is " + $i)
    Write-Host ("the letter is " + $someLetters[$i+1] + " and i is " + $i)
    Write-Host ("the letter is " + $someLetters[$i+2] + " and i is " + $i)
    Write-Host ("the letter is " + $someLetters[$i+3] + " and i is " + $i)
    Write-Host ("the letter is " + $someLetters[$i+4] + " and i is " + $i)
    write-host "finished block of five"
}

gives the output:

the letter is a and i is 0
the letter is b and i is 0
the letter is c and i is 0
the letter is d and i is 0
the letter is e and i is 0
finished block of five
the letter is f and i is 5
the letter is g and i is 5
the letter is h and i is 5
the letter is i and i is 5
the letter is j and i is 5
finished block of five
the letter is k and i is 10
the letter is  and i is 10
the letter is  and i is 10
the letter is  and i is 10
the letter is  and i is 10
finished block of five

Thank you David!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:11:50+00:00Added an answer on June 5, 2026 at 7:11 pm

    You didn’t say what kind of container your objects are in. I’ll assume it’s an array. So, you could do something like this:

    for($i=0; $i -lt $objectArray.length; $i+=5)
    {
        #do something with $objectArray[$i]
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very general question. I'm a self taught 'programmer' who programs in
As a mostly self-taught programmer, I have never really had anyone explain why certain
So I'm somewhat new to programming and mostly self-taught, so sorry if this question
I'm a mostly self taught programmer and one aspect I've never really understood is
I'm a completely self-taught Objective-C programmer, and I need advice on how to best
I am a self taught PHP programmer. So I've never taken any Computer Science
I am a mostly self taught programmer. When I learn a new language it
I'm a self-taught programmer who jumped into Python as my first language about 7-8
I'm a self-taught programmer with no formal training, so please forgive me in advance
So, I'm self-taught in the art of LaTeX, which means there are some really

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.