4

I couldn't find this on the interwebs and it seems like a obvious use case to me

Is it possible run Windows Desired State Configuration / DSC on a Windows 10 workstation?

For example, setting up IIS websites on development machines using DSC in "Push" mode against localhost

Colyn1337
  • 2,397
  • 2
  • 23
  • 40
KCD
  • 958
  • 3
  • 12
  • 24

2 Answers2

3

No.

The internet implies it might be so trying it out, but boy there is a lack of good simple quick start guides so here is what I tried:

# TestDSC.ps1
Configuration TestDSC
{
    Import-DscResource -Module PSDesiredStateConfiguration, xWebAdministration

    WindowsFeature IIS
    {
        Ensure          = "Present"
        Name            = "Web-Server"
    }
    Node localhost
    {
        xWebsite DefaultSite
        {
            Ensure          = "Present"
            Name            = "Default Web Site"
            State           = "Stopped"
            PhysicalPath    = "C:\inetpub\wwwroot"
        }
    }
}

Then run in Powershell:

 .\TestDSC.ps1
 TestDSC

And this should output a localhost.mof in a TestDSC directory

Run in push mode:

Start-DscConfiguration -Wait -Verbose TestDSC

Fails without WinRM

The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig".

But lets try this interesting workaround: https://blogs.technet.microsoft.com/pstips/2017/03/01/using-dsc-with-the-winrm-service-disabled/

$configData = [byte[]][System.IO.File]::ReadAllBytes((Resolve-Path -Path '.\TestDSC\localhost.mof'))
Invoke-CimMethod -Namespace root/Microsoft/Windows/DesiredStateConfiguration -ClassName MSFT_DSCLocalConfigurationManager -Method SendConfigurationApply -Arguments @{ConfigurationData = $configData; force = $true}

Oh no, why didn't you tell me to start with!

PowerShell DSC resource MSFT_RoleResource failed to execute Test-TargetResource functionality with error message: Installing roles and features using PowerShell Desired State Configuration is supported only on Server SKU's. It is not supported on Client SKU.

Windows 10 is not server SKU

Hope this helps save people time, circa 2018 I don't recommend wasting your time investigating any further but look forward to updates from Microsoft (hint hint)

KCD
  • 958
  • 3
  • 12
  • 24
  • so eh, you just cant install features. whats wrong with dsc? – 4c74356b41 Aug 21 '18 at 08:56
  • The question was target a *Windows 10* workstation and this SKU is not permitted. Also try commenting out the `WindowsFeature` block and it will still fail. Happy to be proven wrong but there is virtually no documentation I can find about this use case so I'm trying to share the answers I have found – KCD Aug 22 '18 at 00:22
1

I know I'm incredibly late to the game, but I stumbled across this while looking into IIS with DSC and felt that the answer provided was pretty misleading. As someone who built a career out of using DSC to manage Windows Desktops and Servers, I can comfortably say DSC is supported on all Windows SKUs after Win8/Server 2012. Full stop.

Windows 7, 8, 8.1, 10, 11? Yup.
Windows Server 2012 - 2019 and beyond? Also yes! Windows Containers of all flavors? Absolutely!

The use case given in the question is actually one of the more effective ways of using DSC. If you're wanting to build a Developer workstation with IIS, you absolutely would do well to write a DSC configuration for it. You can then apply this DSC configuration to your local workstation, a VM, or even a Windows container for your team's development work.

It's true to say you cannot use the "WindowsFeature" DSC resource to install IIS on Windows 10 Desktops. But this has nothing to do with DSC support on Windows 10, nor does it even have to do with supporting IIS. This has everything to do with a weird split between two different modules that function almost identically, but for some reason are different.

In Windows Server, the "ServerManager" module gives you access to "Install-WindowsFeature". This is what you'd use to install the IIS feature, and it is also what the "WindowsFeature" DSC resource uses to install/remove features on servers.

In Windows Desktop, the "DISM" module gives you access to "Enable-WindowsOptionalFeature". This is used to install the client version of Hyper-V or the Windows 10 IIS Feature. This is also what the "WindowsOptionalFeature" resource uses to perform the same functions.

Why are they different? Why didn't Microsoft merge these 2 modules into one module that worked on both SKUs? Your guess is as good as mine. But again, spoken as someone who does this for a living, yes you can 100% use DSC on a desktop.

  • I wrote that answer a very long time ago and am somewhat rusty on the names of all the things. Note IIS is just an example here. However, you mention `DISM` which isn't the declarative `DSC`. What is the change you would make to my example to use `DSM` for IIS or anything else? – KCD Mar 01 '23 at 18:48
  • I think you are saying `DSC` works on Windows 10/11 for things other than IIS – KCD Mar 01 '23 at 18:53