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

[Feature Request] Catch Exception from calling EndInvoke and recommend/dynamically reducing Threads #5

Open
Acters opened this issue Aug 9, 2024 · 1 comment

Comments

@Acters
Copy link

Acters commented Aug 9, 2024

This is a feature request to add dynamic Thread reduction when EndInvoke function causes any kind of exception. Otherwise, exit early with a message to recommend for the -Threads parameter to be used.

Specifically this error that I ran into because the default 500 threads is too high for my virtual lab:

Exception calling "EndInvoke" with "1" argument(s): "Thread failed to start."
At C:\temp\IPv4PortScan.ps1:260 char:13
+             $Job_Result = $Job.Pipe.EndInvoke($Job.Result)
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ThreadStartException
 
Exception calling "EndInvoke" with "1" argument(s): "Thread is running or terminated; it cannot restart."
@BornToBeRoot
Copy link
Owner

Hi @Acters,

you can reduce the number of threads by using -Threads 256 (or any other number).

PRs are welcome to improve this script.

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