Home > DevOps > Retrieve all variables in current PowerShell session
Windows PowerShell

Retrieve all variables in current PowerShell session

If you want to see what variables are loaded in the scope of your PowerShell session, it’s really simple.

Get-ChildItem variable:

Command and Output:

PS C:\Users\user\Workspaces\PowerShell> Get-ChildItem variable:

Name                           Value
----                           -----
$                              C:
?                              True
^                              C:
args                           {}
ConfirmPreference              High
ConsoleFileName
DebugPreference                SilentlyContinue
Error                          {}
ErrorActionPreference          Continue
ErrorView                      NormalView
ExecutionContext               System.Management.Automation.EngineIntrinsics
false                          False
FormatEnumerationLimit         4
HOME                           C:\Users\user
Host                           System.Management.Automation.Internal.Host.InternalHost
InformationPreference          SilentlyContinue
input                          System.Collections.ArrayList+ArrayListEnumeratorSimple
MaximumAliasCount              4096
MaximumDriveCount              4096
MaximumErrorCount              256
MaximumFunctionCount           4096
MaximumHistoryCount            4096
MaximumVariableCount           4096
MyInvocation                   System.Management.Automation.InvocationInfo
NestedPromptLevel              0
null
OutputEncoding                 System.Text.ASCIIEncoding
PID                            21248
PowerShellVersion
profile                        C:\Users\user\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1
ProgressPreference             Continue
PSBoundParameters              {}
PSCommandPath
PSCulture                      en-US
PSDefaultParameterValues       {}
PSEdition                      Desktop
psEditor                       Microsoft.PowerShell.EditorServices.Extensions.EditorObject
PSEmailServer
PSHOME                         C:\Windows\System32\WindowsPowerShell\v1.0
PSScriptRoot
PSSessionApplicationName       wsman
PSSessionConfigurationName     http://schemas.microsoft.com/powershell/Microsoft.PowerShell
PSSessionOption                System.Management.Automation.Remoting.PSSessionOption
PSUICulture                    en-US
PSVersionTable                 {PSVersion, PSEdition, PSCompatibleVersions, BuildVersion...}
PWD                            C:\Users\user\Workspaces\PowerShell
ShellId                        Microsoft.PowerShell
StackTrace
TimeStamp
TranscriptFileName             DEVWKS_User_09-16-2019_081128-.txt
true                           True
VerbosePreference              SilentlyContinue
vmtoupdate                     VirtualMachine (Name = 'CENTOS7-T1') [Id = 'd900ff21-6722-4ac6-810e-f76cf609acc4']
WarningPreference              Continue
WhatIfPreference               False