All, first post here. For an exercise I wanted to write an API wrapper in Powershell. Below is the first Get function. It basically works but
I’m wondering if there’s a more elegant way to do the process block. Seems like basically duplicate Foreach loops, but I couldn’t figure out
a better way to handle the two different parameters. I thought I could use $PSItem to
refer to the current object in the pipeline but that doesn’t seem to work. any suggestions?
Also, I’m blind and using a screen reader, so please let me know if there are any glaring formatting issues in this post. Thanks.
I should explain a little better what I’m trying to do. This Function gets the data for a company. One can query by name of the company or it’s id number, so that’s why I used two parameterSets because name and id don’t represent the same value. The query for the Rest call does not appear to allow multiple values, so if I want to get data for companies with id 1 and 3, I have to do 2 separate Rest calls to get that data. I want to be able to do Get-RLCompany -ID 1,3, and do the same with the company name, e.g. Get-RLCompany -Name 'Acme','BabylonInc','ThirdInc'. This is why I’m gathering the data in $Output from each Rest call–each call is only going to return 1 company’s data. Does that make more sense?