Get-Variable - PowerShell


 

Gets the variables in the current console. (Get-Variable)

   

# NAME
Get-Variable

# SYNOPSIS
Gets the variables in the current console.

# SYNTAX
Get-Variable [[-Name] <string[]>] [-Exclude <string[]>] [-Include <string[]>] [-Scope <string>] [-ValueOnly] [<CommonParameters>]

# DESCRIPTION
The Get-Variable cmdlet gets the Windows PowerShell variables in the current console. You can retrieve just the values of the variables by specifying the ValueOnly parameter, and you can filter the variables returned by name.

# PARAMETERS
-Exclude <string[]>
Omits the specified items. Wildcards are permitted.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Include <string[]>
Specifies only the items upon which the cmdlet will act, excluding all others. Wildcards are permitted.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Name <string[]>
Specifies the name of the variable.

Required? false
Position? 1
Default value
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false

-Scope <string>
Gets only the variables in the specified scope. Valid values are "Global", "Local", 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 information, see about_Scopes.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-ValueOnly [<SwitchParameter>]
Gets only the value of the variable.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
System.String
You can pipe a string that contains the variable name to Get-Variable.

# OUTPUTS
Variable object
Get-Variable returns a System.Management.Automation variable object for each variable that it gets. The object type depends on the variable.

# NOTES

This cmdlet does not manage environment variables. To manage environment variables, you can use the environment variable provider.

# EXAMPLE 1

C:\PS>get-variable m*

# Description
-----------
This command displays variables with names that begin with the letter "m". The value of the variables is also displayed.

# EXAMPLE 2

C:\PS>get-variable m* -valueonly

# Description
-----------
This command displays only the values of the variables with names that begin with the letter "m".

# EXAMPLE 3

C:\PS>get-variable -include M*,P* | sort-object name

# Description
-----------
This command gets information about the variables that begin with either the letter "M" or the letter "P". The results are piped to the Sort-Object cmdlet, sorted by name, and displayed.

# EXAMPLE 4

C:\PS>get-variable -scope 0

C:\PS> compare-object (get-variable -scope 0) (get-variable -scope 1)

# Description
-----------
The first command gets only the variables that are defined in the local scope. It is equivalent to "get-variable -scope local" and can be abbreviated as "gv -s 0".

The second command uses the Compare-Object cmdlet to find the variables that are defined in the parent scope (Scope 1) but are visible only in the local scope (Scope 0).

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113336
Set-Variable
New-Variable
Clear-Variable
Remove-Variable

C:\Windows>powershell get-help New-Variable -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole








Windows-10





Windows-10

... facebook.de
... Windows-10 FAQ
... Windows-10 Info


Become a Sponsor
... Your button here?





PowerShell: Gets the variables in the current console.

HTTP: ... PS_Windows/en/Get-Variable.htm
0.25
10673

Is on Windows x64 the x64 version of NonCompressibleFiles faster or better?

 /

What is a cmd.exe?

 /

Portabler Einsatz vom Prozess-Killer unter Windows (10, 8.1, 7, ...)!

 /

Ich habe auf dem Desktop einen kleinen schwarzen Punkt, was kann ich machen?

 /

Die Mausspur bei Windows 8.1 / 10 ist recht nervig, kann man diese abstellen?

 /

How to turn off the intuitive filename sorting in Windows 7, if so, how?

 /

Why can I not read the file list from MS File Explorer?

 /

New Line in Quick text Paste? (\n and nc)

 /

Where is the Windows 10 Start Sound, Logoff, Logon (enable, activate)?

 /

How can I install Java Script in Windows 10?

 /

Change Windows 10 Screen Saver, how to enable or disable?

 /

Create a password reset disk for Windows 8.1 and Win 10 PW recovery?

 /