Author Posts

January 31, 2017 at 5:02 am

Hi

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
——- —-
0.5.0.0 AwsDscToolkit
0.1 AWSExt
3.1.87.0 AWSPowerShell
1.6.0 Azure
1.1.5 Azure.Storage
1.0.11 AzureRM.Automation
1.0.11 AzureRM.profile
0.0.0.13 Docker.PowerShell
2.0.1.4 DSCAdd-one
0.3.0.0 DscResourceCommonTests
0.3.0.0 DscResourceTestHelper
1.0 DSC_PowerCLISnapShotCheck
1.7.4 Image2Docker
2.5.2.0 ISESteroids
4.2.3 NTFSSecurity
1.6 PSVersion

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

January 31, 2017 at 10:35 am

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.

February 2, 2017 at 12:08 am

This is very strange

if I run get-module I get
ModuleType Name ExportedCommands
———- —- —————-
Binary AWSPowerShell {Update-ESDomainConfig, Get-IAMPolicies, Get-R53GeoLocation, Get-R53DDom...
Manifest Microsoft.PowerShell.M... {Remove-WmiObject, Remove-EventLog, Add-Computer, Set-Location...}
Manifest Microsoft.PowerShell.U... {New-Object, Write-Debug, Select-Object, Set-Date...}
Script PSReadline {Set-PSReadlineOption, Get-PSReadlineOption, Get-PSReadlineKeyHandler, R...

then I run the command

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\

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?

any assistance would be appreciated