GithubHelp home page GithubHelp logo

Comments (4)

RamblingCookieMonster avatar RamblingCookieMonster commented on August 21, 2024 1

Alrighty! This was added in #46. You can now use -ImportFunctions

Now that I think about it... there might be some oddities for functions defined in modules - will have to revisit that.

Cheers!

from invoke-parallel.

RamblingCookieMonster avatar RamblingCookieMonster commented on August 21, 2024

Hi Brad!

Invoke-Parallel won't pull in function definitions - as a workaround, if you import the module or load up the functions inside the Invoke-Parallel scriptblock, it should work.

I'll look at adding a parameter to allow including functions from the current PowerShell session, but might take a bit of time.

I still use Invoke-Parallel for a number of ad-hoc tasks and scripts, but do check out @proxb's PoshRSJob; it includes this functionality already, if I recall correctly.

Thanks!

Warren

from invoke-parallel.

bab5470 avatar bab5470 commented on August 21, 2024

I'll look at adding a parameter to allow including functions from the current PowerShell session, but might take a bit of time.

That would be great - thanks.

My reservation with using a PS module is portability of the script. I'd like to keep the code all self contained in one folder so that migrating it to a new server is as simple as copying the script folder.

Having the extra step of having to install a custom module isn't the end of the world but also not ideal either - particularly if a future maintainer isn't familiar with the script.

The reason for trying to use Invoke-Parallel is that I need to kick off a number of backjob jobs (as you may have guessed from my function names) but I also need transcription (powershell logging).

I was attempting to use the powershell start-job native function but I guess that doesn't support transcription when running jobs. :(

Would invoke-parallel support powershell transcripts if i created a POSH module with my custom functions? Any idea if PoshRSJob does either?

Thanks,
Brad

from invoke-parallel.

pathaknikhil87 avatar pathaknikhil87 commented on August 21, 2024

Hi, I am trying to use this function to call my custom function in parallel, but it fails..
1: I am not able to pass multiple input parameters to my custom function
2. Custom Function doesnt respond correctly when invoke using this function

Invoke-Parallel -ScriptBlock { Get-vspherevmname -vmname $_.NAME -org "12345" -vapp "12345"} -InputObject $vm -ImportFunctions

Below is how i call the function individually and using invoke-parallel

PS C:\Users\e554> Get-vspherevmname -vmname $vmv[0].Name -org $org.Name -vapp $Vappp.Name
output: R511-SRVA-WyU3

PS C:\Users\e554> $bab = Invoke-Parallel -ScriptBlock { Get-vspherevmname -vmname $_.NAME -org "ID14434-1-1231231" -vapp "12345"} -InputObject $vmv -ImportFunctions
Output:Catch Block

Can you please help

from invoke-parallel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.