From the course: PowerShell for Security Professionals

Unlock this course with a free trial

Join today to access over 24,400 courses taught by industry experts.

Functions in PowerShell

Functions in PowerShell

Hey, everybody, welcome back to the PowerShell for Security Professionals course. In this video, I wanted to kind of go over how to create functions inside of your PowerShell scripts. So, functions are super important if you remember from other programming languages, because they just allow us to reuse our code. And actually, creating functions inside of PowerShell is extremely simple. So, this is basically the syntax to create a function. All we have to do is declare function by typing the word function and everything following that is the name of the function. After that, we open up with curly braces, and then, we can put all of the code that we want to run inside of our function. And then when we're done. we can just go ahead and call the function as if you would call a commandlet. So, here, you can see it's already autocomplete into my function. Cool. Let's go ahead and save this. The expected output is that we'll see a version of the PowerShell. We'll see a table of the…

Contents