I have little script to ping and “nslookup” devices in out intranet.
To explain the code and why I do this is because we have trouble with our vpn and the given ip addresses. It’s a mess if I’m honest.
This is what the output looks like with the first code
Now I have to say that I need to ping nealry 9000 devices. I tried it with 1800 devices and it took 30 minutes.
So I wanted to parallelize the loop to ping 20 devices at once (for example).
With the foreach-object loop the handling of the variables is very different and “wrong” (because I don’t know how to use them properly).
And $vpnComputer is empty.
So my question is how to handle the variables right with the foreach-object?
It would be nice if someone can help me or point me to the right direction.
Perhaps I am misunderstanding your intent but leading with ‘Like I said’ gives off a particular vibe. I’d humbly ask to be mindful of that in the future.
I’ve helped enough people to know that mistakes absolutely happen. I make them all the time myself. That’s why I asked, to make sure that was intended to be $bla, which would indicate some of the code wasn’t provided potentially. If the code doesn’t define $bla for what you shared, it’s impossible for me to know what that value is. Running the code as you shared it, errors out because $bla is missing in both of the code shares. In a custom object like that, it’s not nearly as common to use a variable on the left side of a statement, though it is done.
In this case it likely doesn’t matter, it’s merely a property name, but I pointed it out because you need to provide all the details when asking for help, as it does matter depending on the issue a person is running into.
Even if no one is interested now you should share it anyway for any future readers comming here looking for a solution for the same of a similar issue.
That’s great to hear! I presume then switching the order was at least, part of the issue? I think when I ran the code and switched the order it was successful though it may have thrown an error about something else I was missing, but it was likely something else you did have on your end.
If so, let me know and I will mark my answer as the solution (or you can as well).