Looping through all parameters in a function to concatenate all non-null parameters

I'm using PowerShell to grab information from a website, which I've been able to do successfully with Invoke-RestMethod.

The website puts it's various options in the URL itself, such as http://www.contoso.com/?opt1=on&opt2=12345

What I'd like to do is create a function to run the Invoke-RestMethod cmdlet, and have a parameter for each option available.  The Function would have a parameter for each option available to put in the URL, and then concatenate all the non-null parameters into the URi for the Invoke-RestMethod cmdlet.

Is there an easy way to loop through all the parameters in the function to see which one's are in use, and concatenate them into the full URi without calling every parameter individually?

September 6th, 2015 9:53am

$PSBoundParameters contains all parameters that actually have a value.
Free Windows Admin Tool Kit Click here and download it now
September 6th, 2015 11:19am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics