Windows Feature with Source

I’m trying to use DSC to switch from Core to GUI on 2012. I’m using the below in my composite config.

Configuration GuiServer
    param (
    Import-DscResource -ModuleName PDSResorces

    WindowsFeature GuiManagementToosl
        Ensure = 'Present'
        Name =  'Server-Gui-Mgmt-Infra'
        Source = 'wim:D:\sources\install.wim:2'
    WindowsFeature GuiShell
        Ensure = 'Present'
        Name =  'Server-Gui-Shell'
        Source = 'wim:D:\sources\install.wim:2'


The CD is mounted as D: but I’m getting this error.

EventType    : ERROR
TimeCreated  : 8/28/2014 4:11:46 PM
Message      : This event indicates that a non-terminating error was thrown when DSCEngine was executing
               Set-TargetResource on MSFT_RoleResource provider. FullyQualifiedErrorId is DISMAPI_Error__Failed_To_Enab
               le_Updates,Microsoft.Windows.ServerManager.Commands.AddWindowsFeatureCommand. ErrorMessage is The
               request to add or remove features on the specified server failed.
               Installation of one or more roles, role services, or features failed.
               The source files could not be found.
               Use the "Source" option to specify the location of the files that are required to restore the feature.
               For more information on specifying a source location, see
      Error: 0x800f081f

Normally you can install features from the sources\sxs folder too. Just copy the folder into a file share and use it as the source, it might just work.

I tried placing Sorces\SXS on the network with a share that the machine account has access. that got the same error.

Most likely the problem and the solution is this:

You just have to update the WIM image you want to use as the source. I’ve also ran into this problem before, when I wanted to install the GUI on a server core VM. It seems that if your source is “older” - i. e. it doesn’t have the updates - than your target machine, the process breaks. I don’t know why is that, but it can be very annoying.

That makes sense I installed two hotfixes required for DSC to work after I used that source to install.

Do you know if there is issues if the source is has more patches then the VM ?

I don’t know, but to be 100% sure, it’d be a good idea to apply the latest updates to both source and target.

You got a method to do that. your article did not reference where to get the patches. I have the ones I installed on this instance but I would need a pile of .msu files to get it current with windows update.

This is not my article, I just found it on Google. There are of course methods, I know of two that I think are easy to do:

Check this out:
John Savill wrote a script to apply a whole bunch of updates to offline WIM or VHD images.
Everything is explained in his article and in his video here:


Fully update your target, which I guess is a Server Core 2012. Then, fully update a VM that is a Server 2012 with a GUI. Mount its VHD and use it as the source. I think it should then work.

You can use the dism powershell cmdlets to apply a hotfix to a wim. it’s apply-something iirc.

I’m not familiar with Apply cmdlets. The PowerShell DISM module cmdlets are listed here:

The problem with Add-WindowsPackage is, that it can only apply a single update file to an image, which isn’t very useful in itself.

I prefer this script because I just have to supply the path to the image and the path to the root folder where all the updates are, than it does all the work for me. It’s so an extremely useful tool!

Add-WindowsPackage does every .msu or .cab in a folder. In fact just for fun I had a script supply it with ever sub-folder on the WSUS server’s WsusContent folder. It ran for a few hours and complained a lot about patches that could not be applied but it did install a number of them. I have no idea if this is a viable solution yet to fully patch an image and have it work for what I’m trying to do. I will hopefully get a change to test that out today.

You’re right, I was mistaken about Add-WindowsPackage. I never used it because I always use that script. I just looked at it’s help file and must have missed the last example.
Next time I’ll have to test before I talk!

Pointing it at WSUS did the trick. I placed the WIM on a share and DSC did it’s job.

I made the following changes to the script mentioned by Istvan

# Add the Updates to Windows Image
$Updates = Get-ChildItem '\\wsusServer\e$\wsus\WsusContent'
foreach($item in $Updates){
    Add-WindowsPackage  -Path "C:\WS2012R2" -PackagePath  $item.FullName -verbose
add-windowsPackage -Path "C:\WS2012R2" -PackagePath '\\Server\HotfixShare' -verbose

The second add-windowsPackage is for any Hotfix that are not serviced by WSUS.