Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

Ensure-DSC and Module version



  • Hello

    As PS Module version management is a mess, I am looking to call Ensure-DSC with a specific version of a module as it is possible with the Invoke-DscResource unsuccessfully.
    Any exemple might helpfull

    Thanks in advance

    Best Regards

    PhilippeC.


  • inedo-engineer

    Hmmm, I'm not sure if it's possible... I don't know if PowerShell even allows multiple versions of the same module/resource to be installed on the same server?



  • The Invoke-DscRessource allows this.
    Ensure-DSC should be improved, if possible. It's been a long time since Otter was updated 😊

    Invoke-DscResource -Method Test -Name WindowsFeature -Property @{Name='RSAT-AD-PowerShell'; IncludeAllSubFeature=$true; ensure='Present'} -ModuleName @{ModuleName=’PSDscResources’; ModuleVersion=2.2.0.0’} -Verbose
    

    As enhancement, it would be nice to have a function Ensure-Module in order to manage properly PS Module.

    I have done a small set of functions based on PackageManagement but it does not work properly for the Module installation as it does remove the old version.

    ##AH:UseTextMode
    ##AH:Description Définition d'un dépôt
    module PackageManagementSource<$Nom, $Ensure = present, $SourceLocation, $ProviderName = PowerShellGet, $InstallationPolicy = Untrusted>
    {
        Ensure-DscResource
        (
            ConfigurationKey: Name,
            Name: PackageManagementSource,
            Module: PackageManagement,
            Properties: %(Name:$Nom,ProviderName:$ProviderName,SourceLocation:$SourceLocation,InstallationPolicy:$InstallationPolicy,Ensure:$Ensure)
        )
    }
    
    ##AH:UseTextMode
    ##AH:Description Installation de modules PS à partir d'un dépôt
    module PackageManagement<$Module, $Version, $Source = internal-psm, $Ensure = Present>
    {
        log-information Module: $Module - $Version - $Ensure;
        Ensure-DscResource
        (
            ConfigurationKey: Name,
            Name: PackageManagement,
            Module: PackageManagement,
            Properties: %(Name:$Module,RequiredVersion:$Version,Source:$Source,Ensure:$Ensure)
        );
    }
    

    note:
    There are some prerequisites to have PackageManagement 1.4.7.


  • inedo-engineer

    Hi @philippe-camelio_3885,

    For an Ensure-PSModule command, here is what I'm thinking.

    Ensure-PSModule {
       ModuleName: ...
       Version: ...
       MinVersion:...
       MaxVersion:...
       Force: false
       AllowClobber: false
       Repository: ... 
       Credential: ...(I expect this to be a ResourceCredential)
       Scope:...
       Properties: ... (any other additional properties to pass to Install-Module)
    }
    

    Where it just ensures that version (or within the min/max) is installed.

    Am I understanding your request correctly?

    Thanks,
    Rich



  • Hi @rhessinger
    Sorry for the delay

    Yes this is exactly what it should be.


  • inedo-engineer

    Hi Phillipe,

    I created an issue on GitHub, #8, to track adding this to the extension. I'll reply back once there is a CI version released of the extension.

    Thanks,
    Rich


Log in to reply
 

Inedo Website HomeSupport HomeCode of ConductForums GuideDocumentation