Get-Variable

Get PowerShell variables in the current console.

Syntax
      Get-Variable [[-Name] String[] ]
         [-Include string] [-Exclude string] 
            [-valueOnly] [-scope string] [CommonParameters]
Key
   -Name 
       The name of the variable(s), may be piped.

   -include string
       Retrieve only the specified items.
       Wildcards are permitted.

   -exclude string
       Omit the specified items. Wildcards are permitted.
	   
   -valueOnly
       Get only the value of the variable.
		
   -scope string
       The scope in which this alias is valid. 
       Valid values are "Global", "Local", "Private" or "Script", or a number 
       relative to the current scope ( 0 through the number of scopes, where 
       0 is the current scope and 1 is its parent). "Local" is the default.
       For more, type "get-help about_scope".

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Standard Aliases for Get-Variable: gv

Examples

Display variables with names that begin with var:

PS C:\> get-variable p*

Display only the values (compare with selecting the value property from the object):

PS C:\> get-variable p* -valueOnly
PS C:\> get-variable p* | select value

Display and sort variables that begin with either the letter 'S' or the letter 'P':

PS C:\> get-variable -include s*,p* | sort-object name

"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it" ~ Brian W. Kernighan

Related:

Clear-Variable - Remove the value from a variable
New-Variable - Create a new variable
Remove-Variable - Remove a variable and its value
Set-Variable - Set a variable
Environment Variables
Equivalent bash command: env - Display, set, or remove environment variables


© Copyright SS64.com 1999-2013
Some rights reserved