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

  • Home
  • SEARCH
  • 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 9120731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:41:24+00:00 2026-06-17T05:41:24+00:00

I am going through Jerry Lee Ford’s book to study basic concepts of powershell

  • 0

I am going through Jerry Lee Ford’s book to study basic concepts of powershell and I have an exam coming up. I am however stuck at this for loop

for ($i = 1; $i -le 10; $i++) {
Write-Host $i
}

The way I see it:
$i equals 1 and as long as $i is less than or equal to then it gets upped by 1. So according to me, the end value would be 11 since the moment $i turns 10 it still matches the -le condition. However the end value is 10?

What am I overlooking here?

  • 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-17T05:41:25+00:00Added an answer on June 17, 2026 at 5:41 am

    Let’s run through it:

    $i = 1. $i -le 10 is true. Print 1. Increment $i to 2

    $i = 2. $i -le 10 is true. Print 2. Increment $i to 3

    $i = 3. $i -le 10 is true. Print 3. Increment $i to 4

    …

    $i = 9. $i -le 10 is true. Print 9. Increment $i to 10

    $i = 10. $i -le 10 is true. Print 10. Increment $i to 11

    $i = 11. $i -le 10 is false. We stop!!

    So you see from 1 to 10.

    But if you saw the value of $i outside the loop, you will see that it is indeed 11. But the loop stopped printing at 10.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While going through one project, I have seen that the memory data is 8
am going through enterprise session bean material.i have doubts regarding below oints :- 1)
While going through Qt code I had this basic question on the pimpl implementation.
Going through classic data structures and have stopped on linked lists.Just implemented a circular
After going through the discussion here I have one more question now. Lets assume,
While going through parsing a xml doc i have used multiple if-else to parse
Going through some tutorials about sockets, I keep coming across code like that: while(true){
Im going through a project I have taken over, and on the database side
When going through some of my applications in the past, I have noticed that
Going through a very basic tutorial on backbone.js views. The expected behavior is to

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.