Variable provider
PowerShell includes a provider and a drive, which allows variables to be listed, created, and changed using Get-ChildItem
, Test-Path
, and so on.
Get-ChildItem
may be used to list all the variables in the current scope by running the command shown as follows:
Get-ChildItem variable:
The first few variables returned by the command above are shown below. This is the same output as would be seen with Get-Variable
:
Name Value
---- -----
? True
^ if
$ }
args {}
ConfirmPreference High
DebugPreference SilentlyContinue
The output shown includes the built-in variables, user-created variables, and any added modules that might have been imported.
As the provider behaves much like a filesystem, Test-Path
may be used to determine whether a variable exists. Get-Variable...