C#中的Powershell模块-如何设置变量作用域? [英] Powershell module in c# - How to set the variable scope?

查看:90
本文介绍了C#中的Powershell模块-如何设置变量作用域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!

我正在用C#为Powershell编写一个模块.

I´m writing a module for Powershell in C#.

但是我不知道如何设置变量范围,例如:

But I don´t know how to set a variables scope like:

$global:WPKGProfilesXML = "C:\Profiles.xml"

有人可以帮我吗?

推荐答案

这是在Powershell中声明全局变量的一种方法.另一种方法是:

That is one way of declaring a global variable in Powershell.  Another way is:

New-Variable -Name testvar -Value "Hello World" -Scope global



这篇关于C#中的Powershell模块-如何设置变量作用域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆