Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Get-Variable

Get-Variable - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Get a powershell variable


       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.
       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".

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

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