Skip to content

Commit e843c79

Browse files
committed
tip: Add more info to environment variables tip
1 parent 1c0a249 commit e843c79

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/PowerShellTips/2024-05-20-use-get-childitem-to-easily-see-all-environment-variables.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ $tip.CreatedDate = [DateTime]::Parse('2024-05-20')
33
$tip.Title = 'Use Get-ChildItem to easily see all environment variables'
44
$tip.TipText = @'
55
Need to quickly see all of the environment variables on your system? Use the `Get-ChildItem` cmdlet with the `Env:` drive to easily list them all with their values.
6+
7+
Alternatively, you can also use the Environment class functions `GetEnvironmentVariables()` and `GetEnvironmentVariable('EnvironmentVariableName')` to get the same information.
68
'@
79
$tip.Example = @'
810
# List all environment variables and their values.
@@ -14,9 +16,14 @@ dir Env:
1416
1517
# List a specific environment variable. e.g. the PATH environment variable.
1618
Get-ChildItem Env:Path
19+
20+
# Alternatively, you can use the Environment class functions.
21+
[Environment]::GetEnvironmentVariables()
22+
[Environment]::GetEnvironmentVariable('Path')
1723
'@
1824
$tip.Urls = @(
1925
'https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem'
26+
'https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables'
2027
)
2128
$tip.Category = [tiPS.TipCategory]::NativeCmdlet # Community, Editor, Module, NativeCmdlet, Performance, Security, Syntax, Terminal, or Other.
2229
$tip.Author = 'Daniel Schroeder (deadlydog)' # Optional. Get credit for your tip. e.g. 'Daniel Schroeder (deadlydog)'.

0 commit comments

Comments
 (0)