Environment Variables: Unterschied zwischen den Versionen

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
 
(2 dazwischenliegende Versionen des gleichen Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 
== Get environment variable ==
 
== Get environment variable ==
 +
=== Get all using "System.Environment" ===
 +
<source lang="powershell">[Environment]::GetEnvironmentVariables() </source>
 +
 
=== Get using "System.Environment" (Scope = System) ===
 
=== Get using "System.Environment" (Scope = System) ===
 
<source lang="powershell">[Environment]::GetEnvironmentVariable('<VariableName>', 'Machine') </source>
 
<source lang="powershell">[Environment]::GetEnvironmentVariable('<VariableName>', 'Machine') </source>
 
  
  
  
 
== Set environment variable ==
 
== Set environment variable ==
== Set using "System.Environment" (Scope = System) ==
+
''The System.Environment class provides GetEnvironmentVariable and SetEnvironmentVariable methods that allow you to specify the scope of the variable.'' <br>
 +
*User = User
 +
*System = Machine
 +
 
 +
=== Set using "System.Environment" (Scope = System) ===
 
<source lang="powershell">[Environment]::SetEnvironmentVariable("<VariableName>", "<VariableValue>", 'Machine') </source>
 
<source lang="powershell">[Environment]::SetEnvironmentVariable("<VariableName>", "<VariableValue>", 'Machine') </source>
 +
 +
  
  

Aktuelle Version vom 6. Mai 2020, 16:05 Uhr

Get environment variable

Get all using "System.Environment"

[Environment]::GetEnvironmentVariables()

Get using "System.Environment" (Scope = System)

[Environment]::GetEnvironmentVariable('<VariableName>', 'Machine')


Set environment variable

The System.Environment class provides GetEnvironmentVariable and SetEnvironmentVariable methods that allow you to specify the scope of the variable.

  • User = User
  • System = Machine

Set using "System.Environment" (Scope = System)

[Environment]::SetEnvironmentVariable("<VariableName>", "<VariableValue>", 'Machine')




More informations: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7