ComputerManagementDsc icon indicating copy to clipboard operation
ComputerManagementDsc copied to clipboard

WindowsCapability: Specified Windows Capability not found

Open Zachareee opened this issue 8 months ago • 1 comments

Problem description

When trying to run winget configure test configuration.yaml (contents of the yaml file below) using the WindowsCapability resource, I get an error:

  The configuration unit failed while attempting to test the current system state.
Specified Windows Capability 'OpenSSH.Server~~~~0.0.1.0' not found. (Parameter 'Name')
<See the log file for additional details>
Some of the configuration units failed while testing their state.

I've tried it with both OpenSSH.Server and OpenSSH.Client as specified in the wiki example but I had no luck, the log file is not created either

Verbose logs

No logs were created

DSC configuration

# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
properties:
  configurationVersion: "0.2.0"
  resources:
    - resource: ComputerManagementDsc/WindowsCapability
      settings:
        Name: OpenSSH.Server~~~~0.0.1.0
        LogPath: C:\Temp\Logfile.log

Suggested solution

Not sure what is the fix

Operating system the target node is running

OsName               : Microsoft Windows 11 Home
OsOperatingSystemSKU : WindowsHome
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 26100.1.amd64fre.ge_release.240331-1435
OsLanguage           : en-US
OsMuiLanguages       : {en-US, en-GB, ja-JP, ko-KR…}

PowerShell version and build the target node is running

Name                           Value
----                           -----
PSVersion                      7.5.2
PSEdition                      Core
GitCommitId                    7.5.2
OS                             Microsoft Windows 10.0.26100
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

ComputerManagementDsc version

Unsure, ran using winget

Zachareee avatar Jun 26 '25 17:06 Zachareee

Yes, this one has some odd behavior. The issue appears to be related to permissions, but adding securityContext: elevated to the winget YAML results in the same error. I ended up doing this as a workaround:

    - resource: xPSDesiredStateConfiguration/xScript
      directives:
        allowPrerelease: true
        description: Enable Sudo
        securityContext: elevated
      id: sudo
      settings:
        GetScript: |
          @{ Result = (sudo config) }
        TestScript: |
          $Result = (sudo config 2> $null)
          $Result -ne $null -and $Result.Contains("Inline")
        SetScript: |
          sudo config --enable normal
    - resource: xPSDesiredStateConfiguration/xScript
      dependsOn: [sudo]
      directives:
        description: Install OpenSSH Client
      id: openssh
      settings:
        GetScript: |
          $Command = "(Get-WindowsCapability -Online -Name 'OpenSSH.Client~~~~0.0.1.0').State"
          $EncodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($Command))
          $State = (sudo --disable-input powershell -EncodedCommand $EncodedCommand)
          @{ Result = $State }
        TestScript: |
          $Command = "(Get-WindowsCapability -Online -Name 'OpenSSH.Client~~~~0.0.1.0').State"
          $EncodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($Command))
          $State = (sudo --disable-input powershell -EncodedCommand $EncodedCommand)
          $State -Eq 'Installed'
        SetScript: |
          $Command = "Add-WindowsCapability -Online -Name 'OpenSSH.Client~~~~0.0.1.0'"
          $EncodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($Command))
          sudo --disable-input powershell -EncodedCommand $EncodedCommand

gtbuchanan avatar Dec 15 '25 14:12 gtbuchanan