This is an instructional summary of how to install the WASP as a module. 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 new modules in a path that is listed in the PSModulePath
environment variable. 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 main paths you should use, they are:
$env:USERPROFILE
\Documents\WindowsPowerShell\Modules\$env:ProgramFiles
\WindowsPowerShell\Modules\<Module📁>\<Module📃📄's>
Use the first path 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. Microsoft recommends not using this location.
$PSHome\Modules
%Windir%\System32\WindowsPowerShell\v1.0\Modules
You can also add your own paths, but unless you have a specific need, just stick with the two 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 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.
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.
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}
1: Allen, Robert. “How to Install PowerShell Modules.” Active Directory Pro, Active Directory Pro, 9 June 2018, activedirectorypro.com/install-powershell-modules/.