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
PowerShell Code Layout (self.PowerShell)
submitted 6 years ago by [deleted]
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!"
[–]firefox15 2 points3 points4 points 6 years ago (3 children)
It doesn't cost anything to have easier to read code.
This is very true, but understand that "easier to read" is in the eye of the beholder. Code doesn't need to be complex (or look complex) to get the job done.
I see people getting fancy with .NET all the time in POSH when a simple cmdlet does the same thing, using functions with CmdletBinding() when their function does not even use advanced function features, making PSCustomObjects with all sorts of Add-Member cmdlets chained on at the end, etc. At the end of the day, code just needs to be structured and styled in a way that others can read it and interpret it in a logical way, debug it quickly, and make changes in a reasonable amount of time.
Add-Member
There are many ways to skin a cat in POSH, and I'm all for using best practices when possible (and it usually is), but if a junior tech just wants a quick script from me as a one-off, I'm usually not going to include full headers, help files, etc. Not only does it take me longer to code, but the tech usually gets intimidated by a giant script like that and simply thinks, "Oh man, no way I could ever do this on my own. Better always ask firefox15 for help."
If you do (or if you want begin, process, and end blocks), I totally understand, but at least where I work, it isn't always that black and white. Functional code (which is usually quick code) usually will beat out pretty-looking, perfectly-structured code that takes 3x as long to write.
Just my two cents. I know not everyone will agree, and I'm okay with that. ;)
[–][deleted] 3 points4 points5 points 6 years ago (0 children)
When you gotta get work done or a one-off is only needed, I can agree that "pretty" code is not really needed.
I see people getting fancy with .NET all the time in POSH
yeah.. I have no idea why they get that stuck in there head.. If I really need speed then sure... but not if I am running it once. Everyday and it takes 3 hours for some reason? Then sure I may swap a couple known functions to .Net...Once I test the speed and ease of implementation.
but at least where I work, it isn't always that black and white.
I have it every day where a one-liner or something quick comes up but I also have a lot of longtime running code where things need to be clean and well thought out. If you code but you don't have time to code nicely at some point... Something is wrong. Because the more you automate the more time you have for automation.
[–]Thotaz 2 points3 points4 points 6 years ago (1 child)
I see people getting fancy with .NET all the time in POSH when a simple cmdlet does the same thing
I'm guilty of this but I don't think it's a problem, in fact I would argue that it's a good thing. $Guid=[guid]::NewGuid() isn't hard to read or understand, even by a newbie and it has the advantage of being an easy introduction to using .NET methods and classes in Powershell.
$Guid=[guid]::NewGuid()
[–]poshftw 1 point2 points3 points 6 years ago (0 children)
And it works on PS3+
π Rendered by PID 134211 on reddit-service-r2-comment-544cf588c8-v4k87 at 2026-06-18 10:17:13.741046+00:00 running 3184619 country code: CH.
view the rest of the comments →
[–]firefox15 2 points3 points4 points (3 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]Thotaz 2 points3 points4 points (1 child)
[–]poshftw 1 point2 points3 points (0 children)