This project will guide the reader from the beginnings of learning about PowerShell and its standards, to learning about programming fundamentals, OOP, functional programming, and finally, organizing code into a module.
The opener to the series, PowerShell as Your First Programming Language, seeks to explain why PowerShell makes an excellent foray into the world of programming, due to its immediate availability on Windows operating systems and cross-compatibility with Linux and Mac OS.
ℹ️
This article isn't just for those getting into programming or picking up their first language. It is also a general introduction to the programming language known as PowerShell.
2) Programming Fundamentals
Now that you've been introduced to PowerShell, its standards, basic commands, and getting help, it's time to explore the basics of programming with PowerShell. These are the same principles you'd learn with any other language:
Data types
Control flow
Loops
And, much more
💡
The fundamentals you'll learn here are the same fundamentals you'd learn with any other programming languages. Learn once here, and the concepts repeat elsewhere with slight variations in syntax.
3) Object-Oriented Programming
Object-oriented programming (OOP) has a tendency to bewilder, but as with all things, the path to understanding is just a matter of time + effort. You must understand that OOP is simply a way to organize (encapsulate) data into units.
In this lesson, you'll see how to build a template class, and subsequently derive an object from this class.
💡
Because PowerShell is an OOP language, most of the fundamentals you learn here will carry over to other languages like Python, Ruby, JavaScript, etc.
4) Functional Programming
Don't Repeat Yourself (DRY) — DRY code is good code. Repeating the same code in different places causes problems. What if you change the repeated code block in one place, but forget to update it in another? This causes things to break and introduces bugs.
💡
If you find yourself repeating the same code in multiple places, this is the time to create a function. A function is a block of code that helps us repeat a process with consistent inputs and outputs, much like you'd use a specific tool for specific purposes when working with your hands.
5) Creating a PowerShell Module
At some point after writing a number of scripts to automate tasks and workflows, your code files and other dependencies might grow to the extent that you want to organize them into a single package.
💡
Much like Python modules are used to organize libraries, code, variables, functions, classes, and more into packages, PowerShell modules serve this exact purpose.