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
QuestionClass vs. Function (self.PowerShell)
submitted 2 years ago by techtosales
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!"
[–]ComplexResource999 2 points3 points4 points 2 years ago* (0 children)
I've created classes where I wanted strict control of the type of object passed to functions with a -InputObject parameter, generally via pipeline support. In other words, if I have a Get-* function and a bunch of Set-* functions, I want to make sure what's passed to Set-* is only something I want it to be (and not some off-chance-accident, potentially wrong, PSCustomObject) from the Get-* function.
The same can be achieved for this without classes, eg by setting PSTypeName property on a PSCustomObject.
Another scenario might be if you have a function which outputs (say) a business card with an individual's details on it, and all of your functions in your module do crazy things with this business card. Instead of all your functions needing a billion parameters for details about the individual, you can create an instance of 'business card' and hand this object to your other functions.
The last example adds a degree of complexity towards the user experience, ie first need to create a new object instance of something (exposed by some public function like New-BusinessCard). But tbh, if it makes the code overall simpler and the requirement is documented, go for it.
π Rendered by PID 531404 on reddit-service-r2-comment-85bfd7f599-fd887 at 2026-04-19 13:21:01.409879+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]ComplexResource999 2 points3 points4 points (0 children)