If you want to iterate a range on numbers from 1..10 (one to ten) using PowerShell, you can do that with the help of the foreach loop.
Let's take a look with a help of a few examples.
Example 1: One-Liner Example
PS /> 1..10 | ForEach-Object { Write-Host "Number: $_" }
Number: 1
Number: 2
Number: 3
Number: 4
Number: 5
Number: 6
Number: 7
Number: 8
Number: 9
Number: 10
Example 2: Using a PowerShell Script
# foreach 1..10
foreach ($number in 1..10) {
Write-Host "Number: $number"
}

Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!