Created
April 18, 2023 17:51
-
-
Save denelon/23d9f4c565687519ffcc7d5355f64bdb to your computer and use it in GitHub Desktop.
Sample configuration to set a machine scoped environment variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.1 | |
# Requires administrator | |
# Checks for absences of environment variable and sets it if it's not present. | |
properties: | |
configurationVersion: '0.1.0' | |
assertions: | |
- resource: Environment | |
directives: | |
module: PSDscResources | |
settings: | |
Name: 'DSC_EXAMPLE' | |
Ensure: 'Absent' | |
Value: 'Desired State Configuration' | |
Target: 'Machine' | |
resources: | |
- resource: Environment | |
directives: | |
module: PSDscResources | |
settings: | |
Name: 'DSC_EXAMPLE' | |
Ensure: 'Present' | |
Value: 'Desired State Configuration' | |
Target: 'Machine' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the code to your hypothetical PS script that does the same thing to enable the other features this does (DSC, for example) then the argument for this is easier to understand. The gist does mention this is a contrived example though, too. More powerful assertions are available and possible which augment the benefit of this approach. See the Winget Configuration docs for more.