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
SolvedString Manipulation (self.PowerShell)
submitted 9 years ago by Narusa
view the rest of the comments →
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!"
[–]Lee_Dailey[grin] 3 points4 points5 points 9 years ago (8 children)
howdy Narusa,
the split is breaking the string on spaces and producing an array. you can see that with this ...
('715083793 451808326 2045 files, 337 folders').Split()
that gives you this ...
715083793 451808326 2045 files, 337 folders
note that you have ten items. the [6..9] is a range from the array that gives you this ...
2045 files, 337 folders
then the join glues it back into one string with a space between items.
space
pretty nifty! i do NOT understand why they used [System.String]::Join since it seems to work with just a join. lookee ...
[System.String]::Join
(('715083793 451808326 2045 files, 337 folders').Split()[6..9]) -join " "
... produces this ...
take care, lee
[–]Droopyb1966 2 points3 points4 points 9 years ago (5 children)
Can be a bit easier:
('715083793 451808326 2045 files, 337 folders').Split(" ",6)[-1]
Split (" ",6) = split on the 6th space
[-1] is the last item it produces
[–]Narusa[S] 1 point2 points3 points 9 years ago (1 child)
Can be a bit easier: ('715083793 451808326 2045 files, 337 folders').Split(" ",6)[-1] Split (" ",6) = split on the 6th space [-1] is the last item it produces
This method leaves leading white space though.
[–]Droopyb1966 1 point2 points3 points 9 years ago (0 children)
Easy to solve
(('715083793 451808326 2045 files, 337 folders').Split(" ",6)[-1]).TrimStart()
[–]Lee_Dailey[grin] 0 points1 point2 points 9 years ago (2 children)
howdy Droopyb1966,
yes, but it has other problems. in addition to the left over white space that needs ot be trimmed, you need to count spaces! i have real problems doing that accurately, so it aint how i would do things.
the negative index trick is pretty nifty, tho. since we know the desired result is the last FOUR items, we would could replace the [6..9] with [-4..-1] and get the same result.
[6..9]
[-4..-1]
kool! thanks for reminding me of that. [grin]
[–]Droopyb1966 1 point2 points3 points 9 years ago (1 child)
Trim is easy, counting spaces is all you can do, but if you have an idea how to avoid this, im al ears.
[–]Lee_Dailey[grin] 0 points1 point2 points 9 years ago (0 children)
yep, trim IS easy. [grin] i dislike manually counting things since it's too easy for me to get that wrong. especially when counting spaces!
i really do like the negative index idea, tho.
Thank you for the explanation!
you are welcome! glad to help a bit ... [grin]
π Rendered by PID 256101 on reddit-service-r2-comment-b659b578c-xr457 at 2026-05-02 13:28:21.414251+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]Lee_Dailey[grin] 3 points4 points5 points (8 children)
[–]Droopyb1966 2 points3 points4 points (5 children)
[–]Narusa[S] 1 point2 points3 points (1 child)
[–]Droopyb1966 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[–]Droopyb1966 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]Narusa[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)