© Adam Bertram 2020
A. BertramBuilding Better PowerShell Codehttps://doi.org/10.1007/978-1-4842-6388-4_5

5. Create Building Blocks with Functions

Adam Bertram1  
(1)
Evansville, IN, USA
 

Once you create a few PowerShell scripts, you’re bound to start feeling like you’re re-creating the wheel. You will inevitably begin seeing patterns in what solutions you build with PowerShell.

One of the most important concepts when building great PowerShell code is treating code like building blocks. Don’t build unique solutions for all problems. Instead, build blocks in the form of functions and modules and then use those modules.

Over time, you’ll find that you’re saving tons of time by not rewriting the same code you wrote months ago and you only have one piece ...

Get Building Better PowerShell Code: Applying Proven Practices One Tip at a Time now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.