DSC - module does not exist at the PowerShell module path
Asked Answered
I

5

7

This is the error I'm hitting: "The PowerShell provider <module> does not exist at the PowerShell module path nor is it registered as a WMI provider"

I'm not exactly a newbie to PowerShell and DSC, but I'm having a hard time figuring this one out. I have followed the guidance here for troubleshooting. I also found this almost identical question... the only resolution seemed to be rebooting (which I tried).

So I made a configuration which imports a module, OctopusDSC. I left out a lot of parameters during troubleshooting the module import, but here is what I have:

Configuration OctopusServer
{
    Import-DscResource -Module OctopusDSC

    Node "WIN-ABC123" 
    {
        cTentacleAgent OctopusTentacle 
        { 
            Ensure = "Present"
            State = "Started"
            Name = "Tentacle"
            ApiKey = ""
            OctopusServerUrl = ""
            DefaultApplicationDirectory = "C:\Utility"
        }
    }
}

The module exists in C:\Program Files\WindowsPowerShell\Modules both locally and on the server:

C:\>tree "C:\Program Files\WindowsPowerShell\Modules" /f
Folder PATH listing
Volume serial number is 9EC4-62C1
C:\PROGRAM FILES\WINDOWSPOWERSHELL\MODULES
└───OctopusDSC
    │   OctopusDSC.psd1
    │
    └───DSCResources
        └───cTentacleAgent
                cTentacleAgent.psm1
                cTentacleAgent.schema.mof

The module path seems fine (I put carriage returns in at each semi-colon, for readability):

PS C:\> $env:PSModulePath
C:\Users\jasonc\Documents\WindowsPowerShell\Modules;
C:\Program Files\WindowsPowerShell\Modules;
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;
C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell

I can call Get-Module:

PS C:\> Get-Module OctopusDSC -ListAvailable

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0.1      OctopusDSC                          {Get-TargetResource, Set-TargetResource, Test-TargetResource}

I can call Get-DscResource:

PS C:\temp> Get-DscResource  -Name "cTentacleAgent"

ImplementedAs   Name                      Module                         Properties
-------------   ----                      ------                         ----------
PowerShell      cTentacleAgent            OctopusDSC                     {Name, ApiKey, DefaultApplicationDirectory,...

And this is my error:

PS C:\> Start-DscConfiguration -Path .\OctopusServer -Verbose -WhatIf -Wait
What if: [WIN-ABC123]: LCM:  [ Start  Set      ]
What if: [WIN-ABC123]: LCM:  [ End    Set      ]
The PowerShell provider OctopusDSC does not exist at the PowerShell module path nor is it registered as a WMI provider.
    + CategoryInfo          : InvalidOperation: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : ModuleNameNotFound
    + PSComputerName        : WIN-ABC123

Am I missing something??

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.34014
BuildVersion                   6.3.9600.16394
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2

Update

I noticed this problem happens on machines with Microsoft Monitoring Agent installed, but does not happen if that agent is not installed.

After the install, the PSModulePath machine-level environment variable looks like this (split for clarity):

PS C:\> [environment]::GetEnvironmentVariable("PSModulePath","Machine")
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\;
C:\Program Files\Microsoft Monitoring Agent\Agent\PowerShell

If I remove the agent's path, and only leave C:\Windows\system32\WindowsPowerShell\v1.0\Modules\ in there, OctopusDSC is found. I do have to restart WMI Provider Host process to get the environment variable change to take. If I add the path back in... fail.

Now this is confusing to me because the whole time the actual path the module is installed in is C:\Program Files\WindowsPowerShell\Modules, and that is presumbably added to the calculated PSModulePath by PowerShell itself (I assume that because I typically don't see that path set up in the system environment variables).

I have seen elsewhere that duplicating C:\Program Files\WindowsPowerShell\Modules in PSModulePath can cause problems with module resolution. So maybe there are other bugs and sensitivities around it?

I feel like this is kind of an answer, but I am still looking for a workaround, as removing that path is not preferred.

Insectivore answered 24/8, 2016 at 18:48 Comment(4)
Try the command Get-DscResource to see if it can discover cTentacleAgent. Get-Module will only show it's container, not the resource. The problem implies the resource is somehow invalid and I would probably start by checking your PowerShell version (reasonably expectations and all that).Thrift
Just tried it... it found the resource, but the error persists :/. I updated my question with the results.Insectivore
PS version on the server? Can you make sure that your DSC resource does not exist in anything other than Program Files?Thrift
Version 4... (added table above). I checked C:\Windows\System32\WindowsPowerShell\v1.0\Modules and it wasn't in there. And user directory doesn't have any modules.Insectivore
G
1

As a sanity check, look at the dir where your .MOF is being created...are there any other MOF files in there? Start-DscConfiguration runs all of the MOF's in a dir. I renamed my MOF file and could not make an error disappear until finally realizing the error was in the old MOF :(

Geralyngeraniaceous answered 27/8, 2016 at 23:2 Comment(0)
S
1

This is a known issue in WMF 4.0. Are you using WMF 4.0? Switching to WMF 5.0 would fix this issue unless you are hitting Windows 10 update patch issue mentioned by Andy.

Sismondi answered 30/8, 2016 at 20:19 Comment(1)
WMF 4 as provided by Server 2012 R2. Yeah, I was wondering if maybe WMF 5 have this problem.Insectivore
G
0

Did you see this post?

In addition to some patches (from 2015) it also talks about the need to recursively run unblock-file. I think I've run into that before.

Geralyngeraniaceous answered 28/8, 2016 at 22:48 Comment(0)
I
0

If you're running windows 10, a post-aniverary update patch broke this (on 8/25/2016). It should be fixed this coming Tuesday. http://www.zdnet.com/article/windows-10-update-breaks-powershell-and-microsoft-wont-fix-it-until-next-week/

Isothermal answered 28/8, 2016 at 23:58 Comment(0)
L
0

I ran into the same issue...it turns out my problem was a Powershell version mismatch. My workstation is version 5, but the end-point was version 4 (2012 R2 out the box).

After installing WMF 5.1 on the remote sever, it recognized and installed IIS using the xWebAdministration module.

Before that, I got same error that he module wasn't present even though I copied it to the appropriate path. The path variable was the same on another configured web server. Only difference was the Powershell version.

On a side note, I notice that 'C:\Program Files\WindowsPowerShell\Modules' is not in the $env:Path variable of either server (or any of my other machines for that matter)...just the default path of 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\'. Something else must be allowing DSC to recognize the modules in that location (i.e. Get-DscResource finds the modules in the Program Files directory now that the server is on WMF 5. While on 4, it only found the modules in the Windows subfolder).

Lovesick answered 11/3, 2019 at 19:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.