I am trying to call \ create runpace inside a class derived from PSCmdlet. Since PSCmdlet includes a default session state that contains shared data that I want to reuse in the workspace, I wonder if there is a programmatic way to convert the current sessionState to the InitialSessionState execution space?
If there is no such way, I do not quite understand why such information about the session state cannot be used in different scenarios. This is like starting a remote workspace. Can someone explain?
For instance,
namespace CustomCmdlet.Test
{
[Cmdlet("Get", "Test1")]
public class GetTest1 : PSCmdlet
{
protected override void ProcessRecord()
{ WriteObject("1"); }
}
[Cmdlet("Get", "Test2")]
public class GetTest2 : PSCmdlet
{
protected override void ProcessRecord()
{
}
}
We use PowerShell 4.0, if relevant.
source
share