Important PowerShell Variables

by Jun 7, 2017

Here is a list of important PowerShell variables: $pshome is the path to the place where PowerShell lives. $home is the path to your personal profile folder. And $PSVersionTable returns the PowerShell version and the versions of important subcomponents:

 
PS> $pshome
C:\Windows\System32\WindowsPowerShell\v1.0

PS> $HOME
C:\Users\tweltner

PS> $PSVersionTable

Name                           Value                                                                                          
----                           -----                                                                                          
PSVersion                      5.1.14393.0                                                                                    
PSEdition                      Desktop                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                        
BuildVersion                   10.0.14393.0                                                                                   
CLRVersion                     4.0.30319.42000                                                                                
WSManStackVersion              3.0                                                                                            
PSRemotingProtocolVersion      2.3                                                                                            
SerializationVersion           1.1.0.1
 

$profile is the path to your personal autostart script that gets loaded automatically whenever your current PowerShell hosts starts (provided the file exists). $profile.CurrentUserAllHosts is the profile script that is loaded with any host. And $env:PSModulePath lists the folders where PowerShell modules can be stored that are auto-discoverable for PowerShell:

 
PS> $profile
C:\Users\tweltner\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

PS> $profile.CurrentUserAllHosts
C:\Users\tweltner\Documents\WindowsPowerShell\profile.ps1

PS> $env:PSModulePath -split ';'
C:\Users\tweltner\Documents\WindowsPowerShell\Modules
C:\Program Files\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

PS>
 

Twitter This Tip! ReTweet this Tip!