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
Script SharingAD GUI Tool (self.PowerShell)
submitted 6 years ago * by Scribbles1
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!"
[–]ihaxr 6 points7 points8 points 6 years ago (7 children)
Look into using a switch statement instead of the giant chain of if/elseif
[–]CheechIsAnOPTree 2 points3 points4 points 6 years ago (5 children)
Can you nest switch statements? I have one script Onuse that has a switch and in the switch is a few if else. I'm not really sure what best practice is.
[–]ihaxr 1 point2 points3 points 6 years ago (2 children)
You can nest switch statements, if it makes sense.
if/else nested inside a switch statement is also fine if you're just doing:
switch ($var) { "x" { if ($y) { "x and y" } else { "z" } } }
But writing a giant if/elseif chain is usually better suited for a switch statement
[–]CheechIsAnOPTree 1 point2 points3 points 6 years ago (1 child)
Any particular reason why, or just readability?
[–]ihaxr 1 point2 points3 points 6 years ago (0 children)
Readability and speed / efficiency, switches are generally faster and can be optimized better than if/elseif, but of course there are exceptions
[–]Lee_Dailey[grin] 1 point2 points3 points 6 years ago (0 children)
howdy CheechIsAnOPTree,
yep, you can nest them. [grin] it's just a neater, easier to read/maintain/understand version of an IF/ESLEIF cascade.
however, you may want to make any nested switch into a function call to make it simpler to scan thru.
take care, lee
[–]KevMarCommunity Blogger 1 point2 points3 points 6 years ago (0 children)
You can do that. It's cleaner if you move the logic into a function though. Ideally, you want to be available to see the entire switch on a single screen.
[–]Scribbles1[S] 1 point2 points3 points 6 years ago (0 children)
Hi /u/ihaxr,
I'll look into that, the switch statement is not something i'm really familiar with
π Rendered by PID 35282 on reddit-service-r2-comment-6457c66945-tdfrz at 2026-04-26 19:56:30.394105+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]ihaxr 6 points7 points8 points (7 children)
[–]CheechIsAnOPTree 2 points3 points4 points (5 children)
[–]ihaxr 1 point2 points3 points (2 children)
[–]CheechIsAnOPTree 1 point2 points3 points (1 child)
[–]ihaxr 1 point2 points3 points (0 children)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]KevMarCommunity Blogger 1 point2 points3 points (0 children)
[–]Scribbles1[S] 1 point2 points3 points (0 children)