Powershell - Get Variable from C # Cmdlet

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

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

Thanks!

+6
c # powershell cmdlets
source share
1 answer

If you are using PSCmdlet, use the this variable to access it as follows:

 this.SessionState.PSVariable.GetValue() 
+7
source share

All Articles