This is probably a dumb question so forgive me. I've used many cmdlets that have a parameter that is named as a singular object, yet it accepts multiple objects.
This makes sense to me for the parameter to be named singularly. For example:
Process-VM -VMName
However, I'm writing my own function that can do the same; take a singular object or a collection, but I'm having trouble with semantics of naming the parameter singularly.
For example, my function accepts one or more virtual machines. Normally with a collection like this I'd use a foreach loop to enumerate through them, and it would look like
foreach ($vm in $VMNames)
But if I write the parameter singularly it would look something like:
foreach ($vm in $VMName)
For the foreach to make sense to me, my parameter would have to be named plurally but then the function call looks silly to me when I'm passing a single object. Ofc this also deviates from those other well-known cmdlets.
Process-VM -VMNames "myvm"
I feel silly having this problem, but I'm curious how this is handled by someone like Microsoft and their cmdlets.
TIA