What is best practice around PackageManagement module?

Welcome Forums DSC (Desired State Configuration) What is best practice around PackageManagement module?

This topic contains 5 replies, has 3 voices, and was last updated by

 
Participant
2 months, 3 weeks ago.

  • Author
    Posts
  • #109102
    GS

    Participant
    Points: 1
    Rank: Member

    Hello,

    I'm confused about what I'm supposed to do with built in PackageManagement module which comes preinstalled with Windows 2016. I can not update it directly since it was not installed from Gallery and when I install newer version from Gallery I end up with 2 modules and 2 names for all DSC Resources. How do I uninstall built in module or what is best practice here?

  • #109103

    Keymaster
    Points: 1,619
    Helping HandTeam Member
    Rank: Community Hero

    Yeah, unfortunately due to the way protected system files exist, they can't be updated that way (although you can try using -Force). The most you can do is try to delete them, although in many cases the system will attempt to "repair" itself and put them back. It's something I don't think they thought through really well.

    This actually comes up with Pester a lot (see https://github.com/pester/Pester/issues/488 as well as https://github.com/pester/Pester/issues/585); it might be useful to look at what other folks have donee and see what works for you.

  • #109115
    GS

    Participant
    Points: 1
    Rank: Member

    How do I properly refer to latest version of PackageManagement module in such cases when using Import-Module or Import-DSCResource

  • #109127

    Participant
    Points: 527
    Helping Hand
    Rank: Major Contributor

    You can target a version using -RequiredVersion parameter for Import-module cmdlet. There are more ways to control version for this cmdlet. I suggest you to take a look at the help documentation of Import-Module cdmlet.

    for Import-DSCResource, below usage can be done.

    Import-DscResource -ModuleName @{ModuleName='yourModule';ModuleVersion=”1.0″}
    
  • #109147
    GS

    Participant
    Points: 1
    Rank: Member

    I need to load latest version of module. Notation inside Import-DSCresource requires exact module version. Script I'm working on will be used on computers for quite sometime and I want always the latest version of PackageManagement resources to be used. I assume there is no solution to this?

  • #109151

    Participant
    Points: 527
    Helping Hand
    Rank: Major Contributor

    Latest version will be picked by default.

You must be logged in to reply to this topic.