PowerTip: Expand Environmental Variables with PowerShell

Doctor Scripto

Summary: Learn to expand the value of environmental variables by using Windows PowerShell.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find the value of a common environmental variable
           such as %username% or %computername%?

Hey, Scripting Guy! Answer Use the ExpandEnvornmentalVariables static method from the
           System.Environment .NET Framework class, for example:

[System.Environment]::ExpandEnvironmentVariables("%username%")

[System.Environment]::ExpandEnvironmentVariables("%computername%")

0 comments

Discussion is closed.

Feedback usabilla icon