1

Closed

Installer breaks psmodulepath

description

Please check your installer since it incorrectly assigned values into my psmodulepath.

It left out two paths once it updated it's own path.

i.e.
This user env variable path
C:\Users\<User>\Documents\WindowsPowerShell\Modules

This machine env variable path
C:\Program Files\WindowsPowerShell\Modules
Closed Jul 8, 2015 at 5:48 PM by heaths
External PowerShell bug that doesn't include default paths regardless of PSModulePath.

comments

lhartje wrote Mar 6, 2015 at 5:36 PM

This also has the side effect of breaking custom modules in PowerShell DSC. All Import-DSC module calls return the following error:
Invoke-CimMethod : The PowerShell DSC resource <<ModuleName>> does not exist at the PowerShell module path nor is it registered as a WMI DSC resource.
At line:9 char:1
+ Invoke-CimMethod @params
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager:String) [Invoke-CimMethod], CimException
    + FullyQualifiedErrorId : DscResourceNotFound,Microsoft.Management.Infrastructure.CimCmdlets.InvokeCimMethodCommand
The installer adds a PSMODULEPATH entry to HKEY_USERS.Default\Environment with the value:
"%PSMODULEPATH%;C:\Windows\SysWOW64\config\systemprofile\AppData\Local\Apps\Windows Installer PowerShell Module\". 
If there is no value for this environment variable, the default is used (which appears to be):
"WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;%PSMODULEPATH%
The string created by the installer does not include "WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;" which causes Powershell DSC to not be able to find its modules.

Deleting the PSMODULEPATH from HKEY_USERS.Default\Environment and rebooting resolves the DSC issue and allows DSC scripts to run again.

heaths wrote Jul 8, 2015 at 5:47 PM

You didn't comment on which version, but the newer versions also add the default PSModulePaths since PowerShell itself has a long-standing bug (since 2.0) that they don't import the default paths.

Some other installers (including some from them) have also shipped that don't do the same thing - adding %PSModulePath% to itself. My installers append to the list, so alone it wouldn't cause this.

Resolving as external.