I can add a function to my runspacepool using initialsessionstate like this:
$initialSessionState = [InitialSessionState]::CreateDefault()
$definition = Get-Content Function:\Icmp-Ping -ErrorAction Stop
$addMessageSessionStateFunction = New-Object System.Management.Automation.Runspaces.SessionStateFunctionEntry -ArgumentList 'Icmp-Ping', $definition
$initialSessionState.Commands.Add($addMessageSessionStateFunction)
Now u want u add a simple class definition in the same manner:
I tried to use add-type with no success, i also read about type tables, but cant find a matching example for runspacepools. The classes type is unknown to the script in the runspace. At this point I wonder if what i want is possible at all. On the other hand if I can introduce functions and sessionstatevariables like this why not classes?