# Use custom class in runspace

**URL:** <https://forums.powershell.org/t/use-custom-class-in-runspace/19095>\
**Category:** PowerShell Help\
**Created:** [April 15, 2022, 2:56am UTC](https://forums.powershell.org/t/use-custom-class-in-runspace/19095 "2022-04-15T02:56:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![C\_Scott\_Weisler](https://avatars.discourse-cdn.com/v4/letter/c/d2c977/32.png) [@C\_Scott\_Weisler](https://forums.powershell.org/u/C_Scott_Weisler)\
**Post date:** [April 15, 2022, 2:56am UTC](https://forums.powershell.org/t/use-custom-class-in-runspace/19095/1 "2022-04-15T02:56:57Z")

</div>

I have a custom class for asynchronous logging that I want to use in runspaces, either via a runspacepool or Powershell 7’s “Foreach-Object -Parallel”. I am currently loading the custom class via a psm1 file using “using module ‘_modulepath_’”. The custom class is not available to runspaces.

Is there a way to pass the class to a runspace so a new instance of the class can be instantiated in the runspace?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/powershell/original/1X/385e4f9fe133561ad30a814262fe0e0ae6bc3ef0.png) [@system](https://forums.powershell.org/u/system)\
**Post date:** [February 10, 2024, 5:34pm UTC](https://forums.powershell.org/t/use-custom-class-in-runspace/19095/2 "2024-02-10T17:34:08Z")

</div>

Closed on February 10, 2024, 5:34pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
