Hello. I have a Powershell class, with a method, that queries a REST API. That method can take some time (~20-30 seconds) to run, and uses pagination. This means, that each query of 10 records takes 20-30 seconds, and the querying all records takes ~30 minutes.
I would like to use iterator blocks to delay execution. If this WASN’T a class, I’d use the standard pipeline features. If this was C#, I’d use yield return.
How do I create the same construct in PowerShell?
So, my issues:
I don’t see a way to make a generic function in Powershell. So, I could return an object. Not that big of a deal.
Yield return doesn’t exist. Can’t use the pipeline in a class. How do I create an iterator block?