Author Posts

July 23, 2017 at 4:36 pm

Hi , Instead of placing all my code in the main loop, I wanted to create a SUBLOOP . Then call the subloop from the main loop.
For example in Winbatch, I could call a subloop with "GoSub" and use the "Return" statement to return back to the main loop.
How would I do something similar in Powershell?

Thanks
Hil

July 23, 2017 at 5:54 pm

I use foreach within a foreach.
Is that what you're looking for ?

July 24, 2017 at 12:10 am

You're probably looking for:

Do {} until ($something -eq "something")

But without a sample code, is a bit hard to determine your scenario.

July 24, 2017 at 1:30 pm

The nearest thing to your description is to create a function and call that. I'd suggest very strongly that you take the time to investigate how PowerShell works – if you just port over the way you do things in other languages you can end up with very inefficient code