-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
Calling custom functions from inside Invoke-Parallel #27
Comments
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 |
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, |
Alrighty! This was added in #46. You can now use Now that I think about it... there might be some oddities for functions defined in modules - will have to revisit that. Cheers! |
Hi, I am trying to use this function to call my custom function in parallel, but it fails.. 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 PS C:\Users\e554> $bab = Invoke-Parallel -ScriptBlock { Get-vspherevmname -vmname $_.NAME -org "ID14434-1-1231231" -vapp "12345"} -InputObject $vmv -ImportFunctions Can you please help |
I'm trying to call some custom functions inside of Invoke-Parrallel as such:
However when I do this I get the following error:
What am I doing wrong and how can I avoid this error?
As a side note - how to i avoid entering an input variable? I don't think I necessarily have anything to input if that makes sense?
Thanks
Brad
The text was updated successfully, but these errors were encountered: