Skip to content

Conversation

@SteveL-MSFT
Copy link
Member

PR Summary

Add the if() function needed for Bicep support

PR Context

Part of #767

Copy link
Member

@andyleejordan andyleejordan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, this now works:

Q:\src\DSC\bin\debug\dsc.exe -l debug config --parameters '{"parameters": {"colorMode": "light"}}' set --file .\demo.json

with this ternary in Bicep:

@allowed(['light', 'dark'])
@description('Light or dark color mode')
// TODO: Teach DSC how to use Bicep param files
param colorMode string = 'light'

var valueData = colorMode == 'light' ? 1 : 0

var keyPathPrefix = 'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion'

resource systemUsesLightTheme 'Microsoft.Windows/Registry@2025-04-07' = {
    name: 'SystemUsesLightTheme'
    properties: {
        keyPath: concat(keyPathPrefix, '\\Themes\\Personalize')
        valueName: 'SystemUsesLightTheme'
        valueData: {
          DWord: valueData
        }
    }
}

@SteveL-MSFT SteveL-MSFT merged commit 5a2a744 into PowerShell:main May 1, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the if-function branch May 1, 2025 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants