Carbon_EnvironmentVariable

DSC resource for managing environment variables.

Syntax

Carbon_EnvironmentVariable [String] #ResourceName
{
    Name = [string]
    [DependsOn = [string[]]]
    [Ensure = [string]{ Absent | Present }]
    [PsDscRunAsCredential = [PSCredential]]
    [Value = [string]]
}

Description

The Carbon_EnvironmentVariable resource will add, update, or remove environment variables. The environment variable is set/removed at both the computer and process level, so that the process applying the DSC configuration will have access to the variable in later resources.

Carbon_EnvironmentVariable is new in Carbon 2.0.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The name of the environment variable.

true false
Value String

The value of the environment variable.

false false
Ensure String

Set to Present to create the environment variable. Set to Absent to delete it.

false false Present

EXAMPLE 1

Demonstrates how to create or update an environment variable:

Carbon_EnvironmentVariable SetCarbonEnv
{
    Name = 'CARBON_ENV';
    Value = 'developer';
    Ensure = 'Present';
}

EXAMPLE 2

Demonstrates how to remove an environment variable.

Carbon_EnvironmentVariable RemoveCarbonEnv
{
    Name = 'CARBON_ENV';
    Ensure = 'Absent';
}