In search of PowerShell environment variables

When working with PowerShell I’m searching for the same variables over and over again. Every time when I found them again I think the same “Oh yeah, I knew that!”. To minimize my search next time I thought about writing it down.

First question, how do I use these variables? This is pretty straightforward.

$Env:username

Second question, which environment variables can I use? Use the following cmdlet:

Get-Item Env: | sort Name Name Value ---- ----- COMPUTERNAME <computername> HOMEPATH \Users\sa-sp2010-Install LOCALAPPDATA C:\Users\sa-sp2010-Install\AppData\Local PSModulePath D:\SPInstall\SPModule;D:\SPInstall\SPModule;C:\Users\sa-sp2010-Install\Documents\Windows... PROCESSOR_ARCHITECTURE AMD64 CommonProgramW6432 C:\Program Files\Common Files CommonProgramFiles(x86) C:\Program Files (x86)\Common Files ProgramFiles(x86) C:\Program Files (x86) PROCESSOR_LEVEL 6 windows_tracing_flags 3 USERNAME sa-sp2010-Install HOMEDRIVE C: USERPROFILE C:\Users\sa-sp2010-Install SystemRoot C:\Windows TEMP C:\Users\SA-SP2~1\AppData\Local\Temp PUBLIC C:\Users\Public ALLUSERSPROFILE C:\ProgramData APPDATA C:\Users\sa-sp2010-Install\AppData\Roaming ProgramData C:\ProgramData PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC OS Windows_NT CommonProgramFiles C:\Program Files\Common Files PROCESSOR_IDENTIFIER Intel64 Family 6 Model 23 Stepping 10, GenuineIntel ComSpec C:\Windows\system32\cmd.exe SystemDrive C: PROCESSOR_REVISION 170a ProgramFiles C:\Program Files NUMBER_OF_PROCESSORS 2 windows_tracing_logfile C:\BVTBin\Tests\installpackage\csilogfile.log TMP C:\Users\SA-SP2~1\AppData\Local\Temp ProgramW6432 C:\Program Files Path C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPower... USERDOMAIN <DOMAIN> VS100COMNTOOLS C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\ windir C:\Windows

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: