Get-EnvironmentVariable
Get-EnvironmentVariable
Get-EnvironmentVariable
Gets an Environment Variable.
Syntax
Get-EnvironmentVariable `
-Name <String> `
-Scope {Process | User | Machine} `
[-PreserveVariables] `
[-IgnoredArguments <Object[]>] [<CommonParameters>]
Description
This will will get an environment variable based on the variable name
and scope while accounting whether to expand the variable or not
(e.g.: %TEMP%
-> C:\User\Username\AppData\Local\Temp
).
Notes
This helper reduces the number of lines one would have to write to get environment variables, mainly when not expanding the variables is a must.
Aliases
None
Examples
EXAMPLE 1
Get-EnvironmentVariable -Name 'TEMP' -Scope User -PreserveVariables
EXAMPLE 2
Get-EnvironmentVariable -Name 'PATH' -Scope Machine
Inputs
None
Outputs
- System.String
Parameters
-Name <String>
The environment variable you want to get the value from.
Property | Value |
---|---|
Aliases | |
Required? | true |
Position? | 1 |
Default Value | |
Accept Pipeline Input? | false |
-Scope
The environment variable target scope. This is Process
, User
, or
Machine
.
Valid options: Process, User, Machine
Property | Value |
---|---|
Aliases | |
Required? | true |
Position? | 2 |
Default Value | |
Accept Pipeline Input? | false |
-PreserveVariables
A switch parameter stating whether you want to expand the variables or not. Defaults to false. Available in 0.9.10+.
Property | Value |
---|---|
Aliases | |
Required? | false |
Position? | named |
Default Value | False |
Accept Pipeline Input? | false |
-IgnoredArguments [<Object[]>]
Allows splatting with arguments that do not apply. Do not use directly.
Property | Value |
---|---|
Aliases | |
Required? | false |
Position? | 3 |
Default Value | |
Accept Pipeline Input? | false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters
http://go.microsoft.com/fwlink/p/?LinkID=113216 .
Links
:choco-info: NOTE
This documentation has been automatically generated from
Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -Force; Get-Help Get-EnvironmentVariable -Full
.
View the source for Get-EnvironmentVariable