收录日期:2019/10/18 22:16:55 时间:2009-11-11 00:10:21 标签:c#,powershell,cmdlets

I'm writing a C# Cmdlet that needs to get the value of a global script variable. How do I do it?

I noticed that the Runspace has SessionStateProxy.GetVariable method. Can I access the runspace from a C# Cmdlet?

Thanks!

If you're implementing a PSCmdlet use the this variable to access it like so:

this.SessionState.PSVariable.GetValue()