Public/Get-ADPObjectFromID.ps1

function Get-ADPObjectFromID {
    <#
    .SYNOPSIS
        Get a user's ADP Object from AOID or Employee iD

    .DESCRIPTION
        Get a user's ADP Object from AOID or Employee ID

    .PARAMETER IsAOID
        Boolean stating type of ID

    .PARAMETER ID
        String containing AOID or Employee ID

    .PARAMETER Certificate
        Certificate to autenticate to ADP with

    .PARAMETER Token
        Token to authenticate to ADP with

    .PARAMETER UserList
        List of all the users

    .EXAMPLE
        Input Boolean: True = AOID
        Input String: AOID or Employee ID
        Input Object: Certificate
        Input Object: Token
        Return Object: <ADP Object>

    .NOTES
        This is used when passing the full adp worker object from ADP's API

    .FUNCTIONALITY
        Powershell Language
    #>

    [CmdletBinding()]
    param (
        [Parameter( Mandatory = $true,
            Position = 1
        )]
        [bool]
        $IsAOID,
        [Parameter( Mandatory = $true,
            Position = 1
        )]
        $ID,
        [Parameter( Mandatory = $true,
            Position = 2
        )]
        $Certificate,
        [Parameter( Mandatory = $true,
            Position = 3
        )]
        $Token
    )


    $uri = "https://api.adp.com/hr/v2/workers/$ID"

    if (!$IsAOID) {
        $uri = "https://api.adp.com/hr/v2/workers?" + '$' + "filter=workers/workerID/idValue eq '" + $ID + "'"
    }

    $headers = @{
        "Accept"        = "application/json"
        "Authorization" = "Bearer $Token"
    }

    $ProgressPreference = 'SilentlyContinue'
    $response = Invoke-WebRequest -Uri $uri -Method Get -Headers $headers -Certificate $Certificate -UseBasicParsing
    $ProgressPreference = 'Continue'

    if ( $response.StatusCode -eq 204 ) {
        return $null
    }

    return ( $response.Content | ConvertFrom-Json ).workers[0]
}