Author Posts

April 12, 2016 at 9:00 am

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"
        }  
    }  
    
    

}

April 12, 2016 at 10:12 am

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.

April 12, 2016 at 10:17 am

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\"
}

April 14, 2016 at 10:20 am

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

April 14, 2016 at 4:13 pm

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?