function Connect-Somewhere
{
[CmdletBinding(DefaultParameterSetName='A')]
param
(
[Parameter(ParameterSetName='A',Mandatory=$false)]
[Parameter(ParameterSetName='B',Mandatory=$true)]
$ComputerName,
[Parameter(ParameterSetName='B',Mandatory=$false)]
$Credential
)
$chosen = $PSCmdlet.ParameterSetName
"You have chosen $chosen parameter set."
}
# -Computername is optional
Connect-Somewhere
# here, -Computername is mandatory
Connect-Somewhere -Credential test