有 USER 环境变量和 SYSTEM 环境变量。
如果存在,我怎样才能让这个条件只检查 SYSTEM env 变量?
if (-not Test-Path 'env:VariableX ') {
"doesnt exist!"
}
Run Code Online (Sandbox Code Playgroud)
如果将 VariableX 定义为 USER 变量,则不会返回任何内容。我想忽略它,只关注它是否在 SYSTEM env 变量中定义
这会起作用:
if (-not [Environment]::GetEnvironmentVariable('VariableX', 'Machine'))
{
"doesnt exist!"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2752 次 |
| 最近记录: |