PSParallel
PSParallel copied to clipboard
classes are not imported into the parallel runspaces
class Foo {
$I
Foo($i){ $this.I = $i }
}
1..10 | Invoke-Parallel {[Foo]::new($_)}
Error: Invoke-Parallel : Unable to find type [Foo].
@powercode Staffan,
Looking forward to when this class issue is resolved so we don't have to duplicate classes inside and outside of Invoke-Parallel.
Classes scopes and life-cycles are not exposed properly. Unfortunately. It may be pretty hard to support it for PS v5 and most likely support would use non-public APIs. @dlwyatt hit similar problem with implementing mocking for PS classes in pester.
I'd like to collect info from community to understand how to expose classes scopes and lifecycle management properly and maybe write an RFC for it. Please, feel free to contact me with [email protected] and describe problems you faced.