How do I use Resource when module did not finish importing yet?

This topic contains 4 replies, has 3 voices, and was last updated by  Justin King 1 year, 7 months ago.

  • Author
    Posts
  • #37578

    GS
    Participant

    Hello,

    I use File resource to copy module from UNC location to $PSModulePath and then want to use that resource. It's obviously fails since it appears to be a chicken and egg problem. What is the proper way to handle this. My example is below. I want to import xWindowsUpdate module

    configuration InstallWMF
    {
       Import-DscResource –ModuleName 'PSDesiredStateConfiguration'
       Import-DscResource -ModuleName 'xWindowsUpdate'
               
        Node node1
        {  
            
            File xWindowsUpdateModule
            {
                DestinationPath = "C:\Program Files\WindowsPowerShell\Modules"
                 Checksum = "ModifiedDate"   
                Recurse = $true
                 SourcePath = "\\prod\serverops\BuildStandards\deployment\modules\xWindowsUpdate"
                 Type =  "Directory"
                MatchSource = $true
            }
            xHotfix HotfixInstall 
            { 
                Ensure = "Present" 
                Path = "\\prod\serverops\software\wmf\wmf5.0\Win8.1AndW2K12R2-KB3134758-x64.msu" 
                Id = "KB3134758" 
                DependsOn = "[File]xWindowsUpdateModule"
            }  
        }  
        
        
    
    }
    
  • #37581

    Nitin Gupta
    Participant

    Short answer is you can't as DSC requires all resources to be present before it attempts to apply the configuration. However there are ways in which you can make it work depending upon your control of your configuration delivery mechanism. Check my answer in this thread http://stackoverflow.com/questions/36538047/chaining-not-composing-dsc-configurations and see if this is helpful in your case. I would suggest file a uservoice request (https://windowsserver.uservoice.com/forums/301869-powershell) for supporting phases in DSC.

  • #37582

    GS
    Participant

    Unfortunately solution from StackOverflow is not going to work since I'm on WMF4. In fact entire DSC above is trying to install WMF5.0 through DSC.

    I also tried another approach. That is add path to PSModulePath pointing to UNC share where module is located which did not work either since seems DSC does not honor this environment variable since process was already created by this time

            Environment PSModule
    {
        Name = "PSModulePath"
        Ensure = "Present"
        Path = $true
        Value = "\\prod\serverops\BuildStandards\deployment\modules\"
    }
    
  • #37782

    Nitin Gupta
    Participant

    With WMF 4.0 there is probably no way. The problem of updating PSModulePath is fixed in WMF 5.0 RTM.

  • #37795

    Justin King
    Participant

    In WMF4.0 the only "supported" way to do that is to setup a pull server to pull your modules . It doesn't have to be a full IIS server, a SMB pull server is just fine.

    Otherwise, you can still use DS in "push" configuration this way, while using a central repository for your modules.

    Is that what you're looking for?

You must be logged in to reply to this topic.