I want to have a configuration that installs WMF 5.1 if the server requires it (i.e. Windows Server 2012 R2 but not 2016). But I’m having trouble writing a configuration that makes that decision at the time the MOF runs rather than at compile time. For example if you tried this:
The only way to currently handle conditions is to create a custom resource. The Get/Test would probably be pretty much the same but the Set would have an If statement to evaluate the OS version and install as needed. That said, I have never tried updating WMF using Windows DSC. It could be problematic if services are trying to restart in to a new version in the middle of a configuration.
I’ve tried using DSC with xHotfix to upgrade WMF 4.0 to WMF 5.0. It was not successful. Too many changes in DSC between the two versions. You may have better luck with 5.1 though.
Basically your DSC Config will declare the powershell package as required, and when installing, it will check if it’s already running v5, or if it should install the hotfixes/msu for that OS version.
That said, I recommend treating wmf5.1 as a pre-req for DSC when possible (apply retrospectively ad-hoc before managing with DSC and update OS deployment task sequences), to avoid problems with the different versions between v4, v4 ~mark2~ (KB3000850) and v5(.1)…