Runspace pool initial session state

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 6 years, 5 months ago.

  • Author
  • #5941

    by at 2012-10-24 10:19:26

    Hi all,

    I've been cautiously exploring runspace pools to parallelize certain scripts and functions.

    Has anyone worked with customizing the initial session state? I assume this can be used to load up a module once rather than for each new thread, for example. I am not a developer, so I'm having trouble following the developer based examples and details here.

    Here's an example of a few thing's I've tried that won't work:

    $sessionstate = []::CreateDefault()
    $sessionstate.ImportPSModule(“ActiveDirectory”) #doesn’t seem to work

    $sessionstate = []::CreateDefault()
    $sessionstate = $sessionstate.ImportPSModule(“ActiveDirectory”) #doesn’t seem to work

    Is this feasible? Does anyone have any examples or links they could post? Your insight would be greatly appreciated!



    by DonJ at 2012-10-24 10:28:12

    This is probably better in our Advanced forum ;). Moving.

    by at 2012-10-24 12:29:19

    I may have answered my own question. Ran the code above

    $sessionstate = []::CreateDefault()
    $sessionstate.ImportPSModule(“ActiveDirectory”) #doesn’t seem to work

    against a scriptblock that runs get-module... seems to load it up! Doesn't seem to be any more efficient though, will measure a few query times over the next few days.

    by DougFinke at 2012-10-24 15:23:12

    I was able to load my own test.psm1 and run a function, no using a scriptblock. I'm running Windows 8, PowerShell v3, BuildVersion 6.2.9200.16384.

    Let me know what other issues you may be having.


You must be logged in to reply to this topic.