Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we share variable state? #20

Closed
RamblingCookieMonster opened this issue Mar 20, 2015 · 3 comments
Closed

How can we share variable state? #20

RamblingCookieMonster opened this issue Mar 20, 2015 · 3 comments

Comments

@RamblingCookieMonster
Copy link
Owner

Had a question from another medium, boiled down to the lack of shared state (variables).

Will look into implementing something along the lines of Boe's synchronized hash table idea, or Dave Wyatt's Lock-Object.

@daisy613
Copy link

Any idea if this will be implemented? I'm interested in being able to collect data from all runspaces in a single object, and then do something with that object when all runspaces complete.

@RamblingCookieMonster
Copy link
Owner Author

Hi!

Unfortunately, the command is already going a bit overboard with parameters - rather than throw everything into invoke-parallel, I think it makes sense to keep this one separate - that said, if you have any ideas on implementing it in a straightforward way, would love to hear!

You can still do this though. By design, you can simply do:

$whatever = 1..100 | invoke-parallel {
    # Some silly example
    [pscustomobject]@{
        ComputerName = "Server$_"
        Blah = 1
    }
}

If you run into issues with certain items freezing, would could skip items that time out -NoCloseOnTimeout -RunSpaceTimeout 45 would ignore any item that takes longer than 45 seconds to run. Keep in mind memory from those frozen runspaces is chewed up until your powershell instance closes - usually not a problem, but worth knowing about.

On top of this, the two links from the issue still work pretty well if you want to play around with them.

Cheers!

@RamblingCookieMonster
Copy link
Owner Author

Closing this out for now. If folks have more ideas on this that wouldn't clutter the parameters too much, I'd be open to it.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants