I've written a bunch of classes that reach out to an API and get JSON. When compiled, I get nice commands like get-host, get-version, get-app, etc.
each cmdlet takes an argument like -host or -app.
I've got about 160 of these that I can write but I'm now looking to write a more generic cmdlet that can accept arbitrary parameters and values.
From what I can see, I can't declare parameters as such where i can issue
get-info -app "appname"
or
get-info -host "hostname"
or
get-info -version "5.5"
unless i declare all the parameters of which there could be hundreds. Also, if the parameter is not declared, it throws a nice error
Get-Info : A parameter cannot be found that matches parameter name 'host'.
Is there a way I can not declare any parameters and then parse the arguments manually or is there a something in c# to automatically parse the list of arguments and then assign them to variables named appropriately?
for example
get-info -host "hostname" -backup "backupid"
and the variables host and backup would be set automatically?