Editing
Powershell Environment Configuration
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Creating and modifying environment variables == * [http://technet.microsoft.com/en-us/library/ff730964.aspx Creating and Modifying Environment Variables] (Microsoft TechNet) === Display all environment variables === <syntaxhighlight lang="powershell"> > Get-ChildItem Env: </syntaxhighlight> === Display information about a particular environment variable === <syntaxhighlight lang="powershell"> > $Env:path </syntaxhighlight> === Create a variable for the current session only === <syntaxhighlight lang="powershell"> > $env:TestVariable = "This is a test environment variable." </syntaxhighlight> === User- and machine-level environment variables === To create a persistent user-level environment variable: <syntaxhighlight lang="powershell"> > [Environment]::SetEnvironmentVariable("TestVariable", "Test value.", "User") </syntaxhighlight> * '''"TestVariable"''' is the name of the variable. * '''"Test Value."''' is the value assigned to the variable. * '''"User"''' is the level of the variable. `"User"` makes this a user-level variable. Alternate values are `"Machine"` and `"Process"`. Variables set with `SetEnvironmentVariable()` don't appear using the `Get-ChildItem env:` command until the current shell is closed and a new one is opened, although the value of the variable can be retrieved with <syntaxhighlight lang="powershell"> > [Environment]::GetEnvironmentVariable("TestVariable","User") </syntaxhighlight> === Deleting environment varables === <syntaxhighlight lang="powershell"> > Remove-Item Env:\TestVariable </syntaxhighlight> Or <syntaxhighlight lang="powershell"> > [Environment]::SetEnvironmentVariable("TestVariable", $null, "User") </syntaxhighlight>
Summary:
Please note that all contributions to Littledamien Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Littledamien Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information