You can do this using parameter sets. By putting each parameter in one set and not the other, PowerShell will take care of the rest. You may want to define a default parameter set, as well:
function YourCmdletName { [CmdletBinding(DefaultParameterSetName='ByUserName')] param ( [Parameter(Mandatory = $true, ParameterSetName = 'ByUserName')] [System.String] $UserName, [Parameter(Mandatory = $true, ParameterSetName = 'ByEmployeeId')] [System.String] $EmployeeId ) # In the function's code, you can either test for whether $UserName and/or $EmployeedId are null, or # check $PSBoundParameters.ContainsKey('UserName'), or check $PSCmdlet.ParameterSetName to see whether it # is set to 'ByUserName' or 'ByEmployeeId'. }