1

I'm trying to get Chocolatey installed to manage packages on a a windows VM using Powershell DSC.

I've prepared my configuration file

Configuration chocandfirefox {
    Import-DscResource -ModuleName cChoco
    Import-DscResource -ModuleName cChocoInstaller
    Import-DscResource -ModuleName cChocoPackageInstaller
       
    Node 'localhost' {

        cChocoInstaller installChoco
        {
            InstallDir = "c:\ProgramData\chocolatey"
        }

         cChocoPackageInstaller installGit
        {
             Name = "firefox"
            DependsOn = "[cChocoInstaller]installChoco"
        }

    }
}

But when I try to compile it to a .mof, I'm told

> +     Import-DscResource -ModuleName cChocoInstaller
> +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Could not find the module 'cChocoInstaller'. At
> C:\Users\auser\Documents\PowerShell\DSC\Configuration_chocandfirefox.ps1:4
> char:5
> +     Import-DscResource -ModuleName cChocoPackageInstaller
> +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Could not find the module 'cChocoPackageInstaller'.
>     + CategoryInfo          : ParserError: (:) [], ParseException
>     + FullyQualifiedErrorId : ModuleNotFoundDuringParse

I'm sure I'm missing something fundamental but I've worked through docs on DSC and Chocolatey and can't spot it.

reticentKoala
  • 235
  • 2
  • 9
  • It seems to work when I specify -Name (The specific DSC resource name) Import-DscResource -ModuleName cChoco Import-DscResource -ModuleName cChoco -Name cChocoInstaller Import-DscResource -ModuleName cChoco -Name cChocoPackageInstaller – reticentKoala Nov 16 '21 at 12:12

1 Answers1

0

You should only need to import cChoco.

Looking at one of the examples provided in the GitHub repository, we can see:

Configuration InstallChoco
{
    Import-DscResource -Module cChoco
    Node "localhost"
    {
        cChocoInstaller InstallChoco
        {
            InstallDir = "c:\choco"
        }
        # ...
    }
}

They're using cChocoInstaller after only importing cChoco. cChocoInstaller is a resource within the module cChoco.

James Ruskin
  • 808
  • 7
  • 13