I am having an issue when trying to load modules into Powershell? I think it not loading the modules in the correct path? How do I know where the modules are installed when using install-module from the PSGallery? I am running PowerShell version 5.0.10514.6 and if I run Get-InstalledModule it list Version Name
but I can’t get-command for any listed installed Modules? such as Get-Command -Module Image2Docker should show me the full list of the commands for Image2Docker Module but it comes back with nothing?
is there a way to find out if they are in the correct Path? or where the modules are so I can move them to the directory which is in my $ENV:Path
When you install modules using Install-Module, it will install to ‘C:\Program Files\WindowsPowerShell\Modules’ (by default) or 'C:\Users\Documents\WindowsPowerShell\Modules'. You can control the destination using the -Scope parameter. Default value is ‘AllUsers’ alternatively you can use ‘CurrentUser’.
Get-Command, Import-Module etc. will look for modules in the locations specified in the $env:PSModulePath environment variable.
Check what the paths $env:PSModulePath variable contain
$env:PSModulePath -split ';'
You can add your own paths to that environment variable, just as you would add to the $env:Path variable, so if you don’t see what you expect, or if the variable is missing, just create it yourself.
I have previously seen installers such the VMware PowerCLI installer mess up my $env:PSModulePath environment variable, where I had to recreate it manually.
So I need to add the local user path C:\Users\jsmith484\WindowsPowershell\Modules
I run
PS C:\Windows\system32> $p = [Environment]::GetEnvironmentVariable(“PSModulePath”)
PS C:\Windows\system32> $p += “C:\Users\jsmith484\WindowsPowershell\Modules”
PS C:\Windows\system32> [Environment]::SetEnvironmentVariable(“PSModulePath”,$p)
PS C:\Windows\system32> $env:psmodulepath
C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules;C:\Program Files (x86)\AWS Tools\PowerShell;C:\Program Files\WindowsPowerShell\Modules;C:\Program Files
(x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager;C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement;C:\Program Files (x86)\Microsoft SDKs\Azure\Powe
rShell\Storage\C:\Users\jsmith484\WindowsPowershell\Modules
and now I can see the user module path C:\Users\jsmith484\WindowsPowershell\Modules but when I run find-module it doesn’t work, it returns nothing and if I try to install-module the same?
If I reboot my PC the User module directory is removed from the path?