Public/Get-ShellPhishUsers.ps1

function Get-ShellPhishUsers {
    <#
    .SYNOPSIS
        Retrieve user records from Phish.net.
    .DESCRIPTION
        This is a special method — a filter is REQUIRED. The API will reject
        bare calls to /users without a column/value filter.
    .PARAMETER ApiKey
        Your Phish.net API key. Defaults to $env:PHISH_KEY.
    .PARAMETER Uid
        Numeric user ID.
    .PARAMETER Username
        Phish.net username.
    .EXAMPLE
        PS C:\> Get-ShellPhishUsers -Uid 1
    .EXAMPLE
        PS C:\> Get-ShellPhishUsers -Username wilson
    #>

    [CmdletBinding()]
    param (
        [Parameter(Position=0)]
        [string]$ApiKey = $env:PHISH_KEY,

        [Parameter()]
        [ValidateSet('json','xml','html')]
        [string]$Format = 'json',

        [Parameter(ParameterSetName='ByUid', Mandatory=$true)]
        [string]$Uid,

        [Parameter(ParameterSetName='ByUsername', Mandatory=$true)]
        [string]$Username,

        [Parameter()][string]$OrderBy,
        [Parameter()][ValidateSet('asc','desc')][string]$Direction,
        [Parameter()][int]$Limit,
        [Parameter()][switch]$NoHeader
    )

    switch ($PSCmdlet.ParameterSetName) {
        'ByUid'      { $endpoint = "users/uid/$Uid.$Format" }
        'ByUsername'  { $endpoint = "users/username/$Username.$Format" }
    }

    $qp = Get-CommonQueryParams -OrderBy $OrderBy -Direction $Direction -Limit $Limit -NoHeader:$NoHeader
    Invoke-ShellPhishApi -Endpoint $endpoint -QueryParams $qp -ApiKey $ApiKey
}