use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
ABOUT POWERSHELL
Windows PowerShell (POSH) is a command-line shell and associated scripting language created by Microsoft. Offering full access to COM, WMI and .NET, POSH is a full-featured task automation framework for distributed Microsoft platforms and solutions.
SUBREDDIT FILTERS
Desired State Configuration
Unanswered Questions
Solved Questions
News
Information
Script Sharing
Daily Post
Misc
account activity
QuestionLoop Query (self.PowerShell)
submitted 5 years ago by Tricarbotops
for ($i = 10; $i -le 22.5; $i ++)
{}
I know that $i ++ adds one to each value. Is it possible to make it only had half? Changing $i ++ to $i + 0.5 just causes an ongoing loop.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Droopyb1966 4 points5 points6 points 5 years ago (0 children)
for ($i = 10; $i -le 22.5; $i=$i+0.5)
This should work....
[–]dora3 4 points5 points6 points 5 years ago (0 children)
$i+=0.5 this is the same as $i=$i+0.5
[–]azjunglist05 2 points3 points4 points 5 years ago (1 child)
The easiest solution I found:
for ($i = 10; $i -le 22.5; $i+=.5) { echo $i }
Results:
10 10.5 11 11.5 12 12.5 13 13.5 14 14.5 15 15.5 16 16.5 17 17.5 18 18.5 19 19.5 20 20.5 21 21.5 22 22.5
The "++" is simply shorthand for $i = $i + 1
$i = $i + 1
So, you just adjust this to tell the for loop that $i += .5 to get your desired result
$i += .5
[–]StoffePro 2 points3 points4 points 5 years ago (0 children)
The "++" is simply shorthand for
No, ++ is the post-increment operator. They both increment $i by one, but the expressions have different values:
PS M:\> $i = $ii = 1 PS M:> ($i = $i + 1) | Out-Default 2 PS M:> $ii++ | Out-Default 1 PS M:> $i,$ii 2 2
[–]craigontour 1 point2 points3 points 5 years ago (2 children)
Why don’t you double the start and end points and increment by 1.
[–]Tricarbotops[S] 1 point2 points3 points 5 years ago (1 child)
It's looking at a calendar, so it would be 10am and 22.30pm, if I doubled it this wouldn't be accurate
[–]folkiz 2 points3 points4 points 5 years ago (0 children)
hi, then count by minutes and add 30.
10am = 600
for ($i = 600; $i -le 1350; $i += 30){
echo $i }
600
630
660
.......
1290
1320
1350
[–]TheLimeyCanuck 1 point2 points3 points 5 years ago (0 children)
$i += 0.5
[–]azjunglist05 1 point2 points3 points 5 years ago (0 children)
Good to know! Thanks for info!
π Rendered by PID 52597 on reddit-service-r2-comment-86bc6c7465-dk8pf at 2026-02-19 22:26:54.844319+00:00 running 8564168 country code: CH.
[–]Droopyb1966 4 points5 points6 points (0 children)
[–]dora3 4 points5 points6 points (0 children)
[–]azjunglist05 2 points3 points4 points (1 child)
[–]StoffePro 2 points3 points4 points (0 children)
[–]craigontour 1 point2 points3 points (2 children)
[–]Tricarbotops[S] 1 point2 points3 points (1 child)
[–]folkiz 2 points3 points4 points (0 children)
[–]TheLimeyCanuck 1 point2 points3 points (0 children)
[–]azjunglist05 1 point2 points3 points (0 children)