Rules/Test-ForParameterSetAmbiguity.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function Test-ForParameterSetAmbiguity
{
    param(
    [Parameter(ParameterSetName='TestCommandInfo',Mandatory=$true,ValueFromPipeline=$true)]
    [Management.Automation.CommandInfo]
    $CommandInfo
    )
    
    
    process {    
        if ($CommandInfo.ParameterSets.Count -gt 1 -and 
            -not ($CommandInfo -as [Management.Automation.CommandMetadata]).DefaultParameterSetName) {
            Write-Error "$CommandInfo has more than one parameter set, but no default."
            
        }
        
    }
}