If a parameter is not an array show a different parameter.

Hey guys, I want to accept a string array or not, but if it is an array that is inputted then i want to allow another parameter (set).

Basically, if someone inputs an array of folders then i don’t want to allow an recursive switch, but if they provide a single path then i do want to allow recursive.

param (
[parameter(Mandatory = $true, ValueFromPipeline = $True)]



Unless I am missing something that won’t ‘hide’ the -recursive switch if $FolderPath.Count -gt 1…

I’m wanting to hide that switch like when you use ParameterSets.


(or it just may not be possible)

Never mind. I decided to just allow it for both.

I was simply trying to point out your logic might be based on that property. The rest of your intent was unclear to me, sorry. The way I understood the question was determine if multiple entries and branch accordingly. In that same logic, you could also determine to use the Recursive switch or not.

Hi Gary,

Please refer to Dynamic Parameters and ArgumentCompleter, you will get some idea about how to handle this scenario.

Thank you.