8

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!

Yuval Peled
  • 4,988
  • 8
  • 30
  • 36

1 Answers1

8

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

this.SessionState.PSVariable.GetValue()
Keith Hill
  • 194,368
  • 42
  • 353
  • 369