[英]Best way to using Global Variables in PowerShell?
I want to use variables over PowerShell instances away. 我想在PowerShell实例上使用变量。 (I know that global variables are not nice) Is this the best way to define a variable over instances in PowerShell?
(我知道全局变量并不好)这是在PowerShell中为实例定义变量的最佳方法吗? Other ideas?
其他想法? ($global:variable is not over PowerShell instances away)
($ global:变量不在PowerShell实例上)
[Environment]::SetEnvironmentVariable("TestVariable", "Test value.", "User")
[Environment]::GetEnvironmentVariable("TestVariable","User")
Yes. 是。 Other options would be to:
其他选择是:
But adding a user environment variable is also a good way to go and the way you suggest is what is needed for the environment changes to survive exiting the current PowerShell session. 但是添加用户环境变量也是一种很好的方法,您建议的方式是在退出当前PowerShell会话后环境变化所需的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.