Cmdlets

Choose a cmdlet from the list on the left or search for a specific cmdlet. Choose a cmdlet from the list or search for a specific cmdlet.
About Help  Providers
 

Set-PathVariable

Set-PathVariable

pscx.dll

Synopsis

PSCX Cmdlet: Sets the specified path-oriented environment variable.

Syntax

Set-PathVariable [-Value] [-Name] [-Target] [<CommonParameters>]

Detailed Description

Sets the specified path-oriented environment variable by taking the paths specified by the Value parameter and concatenating them into a semi-colon separated string.

Parameters

-Value <String[]>

The paths to concat together with semi-colon separators.

Aliases

None

Required?

true

Position

1

Default value

None

Accept pipeline input?

true (ByValue)

Accept wildcard characters?

false

-Name <String>

The name of the environment variable to set. Typically either Path (default), Lib, Include, etc.

Aliases

None

Required?

false

Position

named

Default value

Path

Accept pipeline input?

false

Accept wildcard characters?

false

-Target <EnvironmentVariableTarget>

Specifies which target scope to modify. The valid values are Process (default), User or Machine. Using either the User or the Machine target scope will cause the new value to persist.

Aliases

None

Required?

false

Position

named

Default value

Process

Accept pipeline input?

false

Accept wildcard characters?

false

Input Type


Return Type


Notes

Examples

-------------------------- EXAMPLE 1 --------------------------

Sets the Lib environment variable (creating it if necessary) to the value "C:\Lib;C:\ProjA\Lib" in the Process scope.

Set-PathVariable Lib C:\Lib, C:\ProjA\Lib

-------------------------- EXAMPLE 2 --------------------------

Sets the Lib environment variable (creating it if necessary) to the value "C:\Lib;C:\ProjA\Lib" in the User scope. This enviornment variable will be persisted across PowerShell sessions.

Set-PathVariable Lib C:\Lib, C:\ProjA\Lib -Target User

-------------------------- EXAMPLE 3 --------------------------

Gets the Machine scope Path environment variable while removing unnecessary quotes and empty paths and then sets it to the updated value. This enviornment variable will be persisted across PowerShell sessions.

Get-PathVariable Path -RemoveEmptyPaths -StripQuotes -Target Machine | Set-PathVariable Path -Target Machine

Get-PathVariable
Add-PathVariable
Push-EnvironmentBlock
Pop-EnvironmentBlock