Posts Tagged "Environment variables"

How to use environment variables in Powershell?

Posted by on Nov 6, 2010 in Environment, Powershell | 0 comments

Sometimes you need to use an environment variable (eg. username, userprofile, computername, …) in Powershell. The location where environment variables are stored is “env:”. This behaves similar to a hard or flash drive. You can list its content or browse it by using dir env: The output shows all existing environment variables you can use. But how to use them? You can get every environment variable by using the get-content or for short gc cmdlet. $computername = get-content env:computername $username = gc env:username List of environment variables in Windows 7 /...

Read More