Public/Get-ServiceNowChangeRequest.ps1

function Get-ServiceNowChangeRequest {
    [OutputType([System.Management.Automation.PSCustomObject])]
    [CmdletBinding(DefaultParameterSetName = 'Session', SupportsPaging)]
    Param(
        # Machine name of the field to order by
        [Parameter()]
        [string] $OrderBy = 'opened_at',

        # Direction of ordering (Desc/Asc)
        [Parameter()]
        [ValidateSet('Desc', 'Asc')]
        [string] $OrderDirection = 'Desc',

        # Maximum number of records to return
        [Parameter()]
        [int] $Limit,

        # Fields to return
        [Parameter()]
        [Alias('Fields')]
        [string[]] $Properties,

        # Hashtable containing machine field names and values returned must match exactly (will be combined with AND)
        [Parameter()]
        [hashtable] $MatchExact = @{},

        # Hashtable containing machine field names and values returned rows must contain (will be combined with AND)
        [Parameter()]
        [hashtable] $MatchContains = @{},

        # Whether or not to show human readable display values instead of machine values
        [Parameter()]
        [ValidateSet('true', 'false', 'all')]
        [string] $DisplayValues = 'true',

        [Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory)]
        [ValidateNotNullOrEmpty()]
        [Alias('ServiceNowCredential')]
        [PSCredential] $Credential,

        [Parameter(ParameterSetName = 'SpecifyConnectionFields', Mandatory)]
        [ValidateScript( { $_ | Test-ServiceNowURL })]
        [Alias('Url')]
        [string] $ServiceNowURL,

        [Parameter(ParameterSetName = 'UseConnectionObject', Mandatory)]
        [ValidateNotNullOrEmpty()]
        [hashtable] $Connection,

        [Parameter(ParameterSetName = 'Session')]
        [ValidateNotNullOrEmpty()]
        [hashtable] $ServiceNowSession = $script:ServiceNowSession
    )

    $result = Get-ServiceNowTableEntry @PSBoundParameters -Table 'change_request'

    If ( $result -and -not $Properties) {
        $result | ForEach-Object { $_.PSObject.TypeNames.Insert(0, "ServiceNow.ChangeRequest") }
    }
    $result
}