Powershell 环境变量
来源:互联网 发布:java手动编译 编辑:程序博客网 时间:2024/06/14 01:49
(1)获取所有环境变量
function getAllEnv(){ return (Get-Item Env:)}//this is a array$configs = getAllEnv$configs.length$configs[0]foreach($config in $configs){ $config}
(2)获取特定的环境变量
function getEnvValue([string]$param){ return (get-item env:$param).Value }//orfunction getEnvValue([string]$param){ return (get-item env:$param | get-content) }// test getEnvValue "os" //the result is : Windows_NT
注:获取环境变量是不需要区分大小写的,下面是个都将获得同样的结果
getEnvValue "os"getEnvValue "OS"getEnvValue "oS"getEnvValue "Os"
实际上,几乎整个 powershell 内置方法中对大小写都没有强制。
如上面的用到的 get-item 也可以换成 Get-Item。
(3)设置环境变量
$env:VariableName = 'new-value'//or[Environment]::SetEnvironmentVariable("TestVariableName", "My Value1", "My Value2")
上面的第二种方法是为环境变量设置多个参数
(4)删除环境变量
env:VariableName = ''//orremove-Item env:VariableName
0 0
- Powershell环境变量
- Powershell 环境变量
- PowerShell环境中设置环境变量
- powershell脚本配置jdk环境变量
- 使用PowerShell修改操作系统“环境变量”
- PowerShell获取系统环境变量的方法
- 做一个自动配置JDK环境变量的Powershell脚本
- PowerShell
- PowerShell
- PowerShell
- PowerShell
- PowerShell
- PowerShell
- PowerShell
- powershell
- Powershell
- PowerShell
- Powershell
- Word2vec与LDA的聚类区别
- 151. Reverse Words in a String
- android进程间通信:使用AIDL
- 数据库SQL优化大总结之 百万级数据库优化方案
- Android 启动手机上的APP应用
- Powershell 环境变量
- 封装iOS自定义控件的体会
- C++中ShallowCopy和DeepCopy的区别
- 终于转到IOS的学习了!!
- Oracle11g数据库空表不能导出解决办法
- Platform Dependent Compilation
- Thymeleaf中each标签遍历list如何获取index
- Objective-C Runtime 相关资料
- 选择HttpHandler还是HttpModule?