Public/Get-GhostMember.ps1

function Get-GhostMember {
    <#
    .SYNOPSIS
        Gets members from the Ghost site.

    .DESCRIPTION
        A member is somebody who signed up on the site: for free, or with a subscription to a paid tier. Without
        parameters every member is returned, newest first. Ghost returns members in pages; all pages are retrieved
        unless -Limit or -Page is used, in which case exactly that page is returned.

        Use -Id to get a single member, -Search to look for a part of a name or an email address, and -Filter
        for anything else.

        A member is a person: the result holds email addresses and names. Keep it out of a log.

    .EXAMPLE
        Get-GhostMember -Limit 10

        Returns the ten members that signed up last.

    .EXAMPLE
        Get-GhostMember -Filter 'status:paid+label:vip'

        Returns the paying members that have the label with the slug vip.

    .EXAMPLE
        Get-GhostMember -Search 'jamie'

        Returns the members with jamie in their name or their email address.

    .EXAMPLE
        Get-GhostMember -Filter "email:'jamie@example.com'" -Include metafields

        Returns one member by email address, with the values of the custom fields.

    .LINK
        https://docs.ghost.org/admin-api/members/overview
    #>

    [CmdletBinding(DefaultParameterSetName = 'Browse')]
    [OutputType('Ghost.Member')]
    param(
        # Id of the member to get.
        [Parameter(Mandatory, ParameterSetName = 'Id', Position = 0, ValueFromPipelineByPropertyName)]
        [ValidateNotNullOrEmpty()]
        [string] $Id,

        # Filter in the Ghost query language (NQL), such as status:paid, label:vip or subscribed:true.
        [Parameter(ParameterSetName = 'Browse')]
        [string] $Filter,

        # Text to look for in the names and the email addresses.
        [Parameter(ParameterSetName = 'Browse')]
        [string] $Search,

        # Sort order, such as 'email asc' or 'created_at desc'.
        [Parameter(ParameterSetName = 'Browse')]
        [string] $Order,

        # Number of members in a page, 100 at most. Returns a single page instead of every member.
        [Parameter(ParameterSetName = 'Browse')]
        [ValidateRange(1, 100)]
        [int] $Limit,

        # Number of the page to return. Returns a single page instead of every member.
        [Parameter(ParameterSetName = 'Browse')]
        [ValidateRange(1, [int]::MaxValue)]
        [int] $Page,

        # Related data to include: newsletters, labels, tiers, metafields for the values of the custom fields,
        # and email_recipients for the emails that were sent to the member.
        [ValidateSet('newsletters', 'labels', 'tiers', 'metafields', 'email_recipients')]
        [string[]] $Include
    )

    begin {
        Test-GhostConnection
        $resources = Get-GhostAPIData -Endpoint $MyInvocation.MyCommand.Name
    }

    process {
        try {
            # Every page is retrieved unless the caller asked for a specific one.
            $singlePage = $PSBoundParameters.ContainsKey('Limit') -or $PSBoundParameters.ContainsKey('Page')
            $paginate = $PSCmdlet.ParameterSetName -eq 'Browse' -and -not $singlePage

            $uri = New-URIString -Endpoint $resources.URI[$PSCmdlet.ParameterSetName] -Parameters $PSBoundParameters
            $uri = New-QueryString -Uri $uri -QueryKeys $resources.Query -Parameters $PSBoundParameters
            $result = Submit-Request -Uri $uri -Method $resources.Method -Success $resources.Success -Paginate:$paginate
            $result = Test-ReturnFormat -Result $result -Location $resources.Result

            Set-ObjectTypeName -InputObject $result -TypeName $resources.TypeName
        }
        catch {
            $PSCmdlet.ThrowTerminatingError($_)
        }
    }
}