NetworkingDsc icon indicating copy to clipboard operation
NetworkingDsc copied to clipboard

NetworkingDsc: "Import-DscResource Could not find the module" due to ModuleVersion Key not matching Folder Directory

Open WMPCraig opened this issue 6 years ago • 4 comments

ISSUE DESCRIPTION

I am able to Install-Module successfully. However when try to Import-DSC Resource within my configuration PowerShell shows an error "Could not find the module 'NetworkingDsc'

When running Test-ModuleManifest there is an issue with the ModuleVersion Key not matching the folder name

Test-ModuleManifest : The ModuleVersion key in module manifest 'C:\Program Files\WindowsPowerShell\Modules\NetworkingDsc\7.3.0\NetworkingDsc.psd1' specifies module version '7.3.0.0' which does not match its version folder name at 'C:\Program Files\WindowsPowerShell\Modules\NetworkingDsc\7.3.0'. Change the value of the ModuleVersion key to match the version folder name. At line:1 char:1

  • Test-ModuleManifest -Path "C:\Program Files\WindowsPowerShell\Modules ...
  •   + CategoryInfo          : InvalidArgument: (C:\Program File...workingDsc.psd1:String) [Test-ModuleManifest], InvalidOperationException
      + FullyQualifiedErrorId : Modules_InvalidModuleManifestVersion,Microsoft.PowerShell.Commands.TestModuleManifestCommand
    
    

Details of the scenario you tried and the problem that is occurring

Verbose logs showing the problem

Install-Module NetworkingDsc -Repository WMP_Share -Force -Verbose

VERBOSE: InstallPackageLocal' - name='NetworkingDsc', version='7.3.0',destination='C:\Users\USR _Name\AppData\Local\Temp\1411520941' VERBOSE: Catalog file 'NetworkingDsc.cat' is not found in the contents of the module 'NetworkingDsc' being installed. VERBOSE: Module 'NetworkingDsc' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\NetworkingDsc\7.3.0'.

At line:8 char:5

  • Import-DscResource -ModuleName NetworkingDsc
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    

Could not find the module 'NetworkingDsc'.

Suggested solution to the issue

The DSC configuration that is used to reproduce the issue (as detailed as possible)

# insert configuration here
configuration DevAMQ
{
    #Import-DscResource -ModuleName PSDscResources
    Import-DscResource -ModuleName xPSDesiredStateConfiguration 
    Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
    Import-DscResource -ModuleName P_ArtemisMQ_Build
    Import-DscResource -ModuleName P_RedHat_Fuse
    Import-DscResource -ModuleName NetworkingDsc


    node $AllNodes.NodeName
    {
        # Set LCM to reboot if needed
        LocalConfigurationManager
        {
            RebootNodeIfNeeded = $false
        }

## Install .Net3.5!!
        WindowsFeature DotNet3.5
        {
            Ensure = "Present"
            Name = "NET-Framework-Features"
            Source = $node.dotNETSource
        }

       Package JavaInstaller
        {
            Ensure          = "Present"
            Name            = $node.JavaName
            Path            = $node.JavaSource
            Arguments       = 'InstallDir="'+$($AllNodes.JavaInstDir)+'\'+$($AllNodes.JavaName)+'"'
            ProductId       = ''
            DependsOn       = "[WindowsFeature]DotNet3.5"
            
        }
        
        xEnvironment Java_Home
        {
            Name   = 'Java_Home'
            Value  = "$($AllNodes.JavaInstDir)\$($AllNodes.JavaName)"
            Ensure = 'Present'
            Path   = $false
            DependsOn = "[Package]JavaInstaller"
        }

        Environment CamelEnc
        {
            Name   = 'CAMEL_ENCRYPTION_PASSWORD'
            Value  = '5eCret'
            Ensure = 'Present'
            Path   = $false
        }


        File CopyArtemisInstaller
        {
            Ensure = "Present"
            Type = "Directory"
            Recurse = $true
            SourcePath = $AllNodes.ArtemisSource
            DestinationPath = $node.AMQ_InstallDir
        }
        
        ArtemisMQ Broker
        {
            Ensure = "Present"
            InstallDirectory = $node.AMQ_BrokerInst
            HostName = "AMQ_$($Node.NodeName)"
            NodeName = $Node.NodeName
            NodeRole = $Node.AMQ_NodeRole
            User = $node.AMQ_User
            UserPassword = $node.AMQ_UserPassword
            ActiveMQInstaller = "$($node.AMQ_InstallDir)\bin\artemis.cmd"
            ClusterUser = $AllNodes.ClusterUser
            ClusterPassword = $AllNodes.ClusterPassword
            ClusterName = $AllNodes.ClusterName
            HAMode = $AllNodes.HAMode
            DependsOn = "[Package]JavaInstaller","[File]CopyArtemisInstaller"
        }

        RedHat_Fuse Primary
        {
            Ensure = 'Present'
            InstallMedia = $AllNodes.FuseSource
            InstallDir = $Node.Fuse_InstallDir
            FuseInstance = $Node.Fuse_Instance
            JavaMin = $node.JavaMin
            JavaMax = $node.JavaMax
            FuseUsers = ConvertTo-Json -InputObject $FuseUsers
            DependsOn = "[Package]JavaInstaller"
        }

        Firewall Fuse_HawtIO
        {
            Name                  = 'NotePadFirewallRule'
            DisplayName           = 'Firewall Rule for Notepad.exe'
            Ensure                = 'Present'
            Enabled               = 'True'
            Profile               = ('Domain', 'Private')
            Direction             = 'OutBound'
            RemotePort            = ('8080', '8081')
            LocalPort             = ('9080', '9081')
            Protocol              = 'TCP'
            Description           = 'Firewall Rule for Notepad.exe'
            Program               = 'c:\windows\system32\notepad.exe'
        }

    }
}

#### The operating system the target node is running
OsName               : Microsoft Windows 10 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 1903
WindowsBuildLabEx    : 18362.1.amd64fre.19h1_release.190318-1202
OsLanguage           : en-US
OsMuiLanguages       : {en-US, en-GB, si-lk}

#### Version and build of PowerShell the target node is running
Name                           Value                                                                                                                                                                                                                 
----                           -----                                                                                                                                                                                                                 
PSVersion                      5.1.18362.145                                                                                                                                                                                                         
PSEdition                      Desktop                                                                                                                                                                                                               
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                               
BuildVersion                   10.0.18362.145                                                                                                                                                                                                        
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                       
WSManStackVersion              3.0                                                                                                                                                                                                                   
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                   
SerializationVersion           1.1.0.1   

#### Version of the DSC module that was used ('dev' if using current dev branch)
7.3.0

WMPCraig avatar Aug 29 '19 15:08 WMPCraig

Are you getting the module from an internal repository? If so then this might track this problem. https://github.com/PowerShell/DscResources/issues/508

johlju avatar Aug 29 '19 16:08 johlju

@johlju I am getting it from our internal repo. Is this the issue or will it be the same from PS Gallery?

WMPCraig avatar Aug 30 '19 09:08 WMPCraig

If you use install-module from the gallery you should not see this issue.

johlju avatar Aug 30 '19 09:08 johlju

FYI: If you're using something like Sonatype Nexus, using a Proxy repository of PSGallery will work just fine.

PlagueHO avatar Aug 30 '19 10:08 PlagueHO