#Powershell import module activedirectory how to
Now that we know the basic concepts of loading a function and how to use it, let’s take the next step and look into modules.Īs I mentioned earlier creating a Powershell Module is as simple as saving multiple functions into a single. Once the function is dot sourced (loaded into memory) you can now call the function with the intended parameters. An example would be C:\_Scripts\script.ps1. Alternatively, if you can use the absolute path regardless of what directory you’re in. The Relative path would be \_Scripts\script.ps1. Let’s say your script is in the C:\_Scripts directory as shown above and your current directory is the root of the C drive. The caveat here is the use of relative or absolute paths. I’ll use my Get-Something sample function. To summarize what dot sourcing looks like in code. Consequently as time went on I started growing my knowledge base and progressed from functions to modules. At first, I’ll admit it was kind of confusing and it took me a while to get the hang of it. In order to load a function in Powershell, we can accomplish this by dot sourcing the file. We’ll cover how to load a module later in the article, however let’s take a dive into how can we load a function.
A big reason I like to create Powershell Modules instead of having the functions in their own file is the fact that modules are so much easier (and less complicated) to load.