Share via


SessionStateKeeper.GetSessionState Method

Definition

This method should be called only from

  • generated ctors for PowerShell classes, AND
  • ScriptBlockMemberMethodWrapper when invoking static methods of PowerShell classes. It's not intended to be a public API, but because we generate type in a different assembly it has to be public. Return type should be SessionStateInternal, but it violates accessibility consistency, so we use object.
public:
 System::Object ^ GetSessionState();
public:
 Platform::Object ^ GetSessionState();
winrt::Windows::Foundation::IInspectable GetSessionState();
public object GetSessionState ();
member this.GetSessionState : unit -> obj
Public Function GetSessionState () As Object

Returns

SessionStateInternal.

Remarks

By default, PowerShell class instantiation usually happens in the same Runspace where the class is defined. In that case, the created instance will be bound to the session state used to define that class in the Runspace. However, if the instantiation happens in a different Runspace where the class is not defined, or it happens on a thread without a default Runspace, then the created instance won't be bound to any session state.

Applies to