【发布时间】:2010-12-15 07:00:14
【问题描述】:
我正在编写一个需要获取全局脚本变量值的 C# Cmdlet。 我该怎么做?
我注意到 Runspace 有 SessionStateProxy.GetVariable 方法。 我可以从 C# Cmdlet 访问运行空间吗?
谢谢!
【问题讨论】:
标签: c# powershell cmdlets
我正在编写一个需要获取全局脚本变量值的 C# Cmdlet。 我该怎么做?
我注意到 Runspace 有 SessionStateProxy.GetVariable 方法。 我可以从 C# Cmdlet 访问运行空间吗?
谢谢!
【问题讨论】:
标签: c# powershell cmdlets
如果您要实现 PSCmdlet,请使用 this 变量来访问它,如下所示:
this.SessionState.PSVariable.GetValue()
【讨论】:
System.Management.Automation.Cmdlet的选项吗?