Level 1
0 / 100 XP

Creating a Custom PowerShell Module: Files and Folders

Now it's time to create a PowerShell module, and we're going to get started by creating the files and folders that we're going to need for this module. And this is actually really exciting because this is a pretty advanced topic, but I'm going to break it down in such a way that anybody can get started doing this again.

You want to make a module whenever you find yourself reusing code over and over again, and maybe different function files or maybe different scripts that you have. Maybe you have a function that you use multiple times throughout multiple scripts. Well, maybe it's time to look at creating your own personal module.

So to get started, what we're going to do is just open PowerShell. And again, I'm running it as an administrator. What we're going to do is find the actual folder path that Where we're going to be installing or creating this module. So again, the environment colon PS module path. This is something that we've done before.

I like to split this dot split, and I like to split it by the semi-colon just because it puts each module path on a single. Now I have this. He uses administrator documents. PowerShell. If I copy this path. I can browse to it. If you get an error message saying you can't browse to this directory, copy back one directory, and just don't do the modules, do the one back, and then you probably have to manually create the modules folder.

It probably just doesn't exist yet. So what we're gonna do… is create our own folder here, and we're going to make a module that is going to compose a kind of like a hello world message or a greeting message that it just gives us a good example of how to create PowerShell modules. We're going to call this module GreetMe, so I'm going to right-click and say new folder, and I'll call it GreetMe.

Now the name of the actual folder does matter. It needs to match the PSM 1 file that we will create inside the folder. Remember, if you name this something else, you need to update all the ot…