Examples/Sample_xEnvironment_CreatePathVariable.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<#
    .SYNOPSIS
        Creates the environment variable 'TestPathEnvironmentVariable' and sets the value to 'TestValue'
        if it doesn't already exist or appends the value 'TestValue' to the existing path if it does
        already exist on the machine and within the process.
#>

Configuration Sample_xEnvironment_CreatePathVariable 
{
    param ()

    Import-DscResource -ModuleName 'xPSDesiredStateConfiguration'

    Node localhost
    {
        xEnvironment CreatePathEnvironmentVariable
        {
            Name = 'TestPathEnvironmentVariable'
            Value = 'TestValue'
            Ensure = 'Present'
            Path = $true
            Target = @('Process', 'Machine')
        }
    }
}

Sample_xEnvironment_CreatePathVariable