This is an instructional summary of how to install the WASP as a module. This brief has been adapted from Robert Allen's tutorial on Active Directory Pro.1
- Choose your module install path
- Ensure DLL is in the WASP directory
- Copy WASP DLL to module path and unblock it
- Import new module
Install the new module by creating a directory named WASP
in one of the paths that are listed in the PSModulePath
environment variable. (Or, you can move the directory WASP
created by archive expansion in one of those paths.) To see the value of PSModulePath
run the following command.
$env:PSModulePath -split ';'
Here is the result of running that command on my computer (you should see similar results).
There may be several paths listed but there are two safe paths you should use, they are:
$env:USERPROFILE
\Documents\WindowsPowerShell\Modules\$env:ProgramFiles
\WindowsPowerShell\Modules\<Module📁>\<Module📃📄's>
Use the first of the above paths if you want the module to be available for a specific user. Use the second path to make the module available for all users.
What are the other paths for?
The path below is reserved for modules that ship with Windows. ⚠ Warning: Microsoft recommends not using this location.1 |
---|
$PSHome\Modules |
%Windir%\System32\WindowsPowerShell\v1.0\Modules |
You can also add your own paths, however, unless you have a specific need, just stick with the two safe paths listed. |
If you see other paths listed in your environment variable, it may be from programs you have installed. Some programs will automatically add PowerShell commands to the variable after installation.
Now that we know where to put new modules, let's move to step 2.
Check that you have the WASP.dll
from the releases in the WASP
module directory.
The next step is to copy the directory WASP
containing the WASP.dll
into one of the two paths identified in step 1. Here, we'll make it available to all users by copying it to the $env:ProgramFiles
destination
C:\Program Files\WindowsPowerShell\Modules
There it is. Copy and paste or extract the module into the path (within a directory named WASP
).
We also need to ask Windows to unblock the DLL, since the file is originally downloaded from the Internet.
Unblock-File -Path "$env:ProgramFiles\WindowsPowerShell\Modules\WASP\WASP.dll"
Now let’s verify the new module is visible to PowerShell, run the following command:
Get-Module -ListAvailable
This command will check the paths that are set in the environment variable for modules.
The screenshot below is what returns when I run this command. I can see that the new module (WASP
) is now visible to PowerShell.
Now that the new module is installed we still have one final step before we can use the new commands.
Importing loads the module into active memory so that we can access the module in our session.
To import run the following command
Import-Module -name WASP
That will do it — the WASP module is now ready to use.
One-liner to import WASP |
---|
if(Get-InstalledModule -Name WASP -ErrorAction Ignore) {Get-Module -ListAvailable -Name WASP | Import-Module} else {Write-Host "You need to install the module first. See https://github.com/mavaddat/wasp/How_to_install_WASP_as_module_in_PowerShell.md" -ForegroundColor Red} |
Did you run into a problem? If so, see the detailed instructions on Microsoft's docs website here.
⮬ 1: Allen, Robert. “How to Install PowerShell Modules.” Active Directory Pro, Active Directory Pro, 9 June 2018, activedirectorypro.com/install-powershell-modules/.
⮬ 2: Installing a PowerShell Module - PowerShell | Microsoft Docs https://docs.microsoft.com/en-us/powershell/scripting/developer/module/installing-a-powershell-module#install-modules-in-psmodulepath