PowerShell:什么样的关键字 ist env: ?这样的关键字是什么意思?
PowerShell: What kind of keyword ist env: ? Meaning of such a keyword?
要在 PowerShell 中显示所有环境变量,请使用:
Get-ChildItem env:
什么是'env:'?
我很清楚这是“环境”的缩写。但是什么样的缩写呢?末尾的冒号是什么意思?
您的查询在 PowerShell 帮助文件中定义:
About Automatic Variables:
$env 是上面的虚拟驱动器。通过下面很容易看到它允许访问上面的目的:
# These are treated as normal filesystem drives, and you can create custom ones.
Get-PSDrive
<#
Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
Alias Alias
C 5.04 34.83 FileSystem C:\ Scripts
Cert Certificate \
Env Environment
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
WSMan WSMan
#>
Get-ChildItem -Path 'env:\'
<#
Using these in code requires the $ in front of each named variable to get the content/values. In your scripts, never name your custom variables the same as any of the below.
Name Value
---- -----
ALLUSERSPROFILE C:\ProgramData
APPDATA C:\Users\WDAGUtilityAccount\AppData\Roaming
CLIENTNAME 8fda9520-99a6-4
CommonProgramFiles C:\Program Files\Common Files
CommonProgramFiles(x86) C:\Program Files (x86)\Common Files
CommonProgramW6432 C:\Program Files\Common Files
COMPUTERNAME 0C092C31-6890-4
...
#>
如果您确实想使用上面的名称作为其他值的自定义变量,那么您应该提供一个唯一的前缀。说,你的名字缩写,免得有conflicts/errors.
要在 PowerShell 中显示所有环境变量,请使用:
Get-ChildItem env:
什么是'env:'?
我很清楚这是“环境”的缩写。但是什么样的缩写呢?末尾的冒号是什么意思?
您的查询在 PowerShell 帮助文件中定义:
About Automatic Variables:
$env 是上面的虚拟驱动器。通过下面很容易看到它允许访问上面的目的:
# These are treated as normal filesystem drives, and you can create custom ones.
Get-PSDrive
<#
Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
Alias Alias
C 5.04 34.83 FileSystem C:\ Scripts
Cert Certificate \
Env Environment
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
WSMan WSMan
#>
Get-ChildItem -Path 'env:\'
<#
Using these in code requires the $ in front of each named variable to get the content/values. In your scripts, never name your custom variables the same as any of the below.
Name Value
---- -----
ALLUSERSPROFILE C:\ProgramData
APPDATA C:\Users\WDAGUtilityAccount\AppData\Roaming
CLIENTNAME 8fda9520-99a6-4
CommonProgramFiles C:\Program Files\Common Files
CommonProgramFiles(x86) C:\Program Files (x86)\Common Files
CommonProgramW6432 C:\Program Files\Common Files
COMPUTERNAME 0C092C31-6890-4
...
#>
如果您确实想使用上面的名称作为其他值的自定义变量,那么您应该提供一个唯一的前缀。说,你的名字缩写,免得有conflicts/errors.