functions/Get-DrmmAccountDevices.ps1

function Get-DrmmAccountDevices {

    <#
    .SYNOPSIS
    Fetches the devices of the authenticated user's account.
 
    .DESCRIPTION
    Returns account device settings, device type, patch management and UDF's.
 
    DevicesPage {
    devices (Array[Device]),
    pageDetails (PaginationData)
    }
    Device {
    a64Bit (boolean, optional),
    antivirus (Antivirus, optional),
    cagVersion (string, optional),
    creationDate (integer, optional),
    deleted (boolean, optional),
    description (string, optional),
    deviceClass (string, optional) = ['device', 'printer', 'esxihost', 'unknown'],
    deviceType (DevicesType, optional),
    displayVersion (string, optional),
    domain (string, optional),
    extIpAddress (string, optional),
    hostname (string, optional),
    id (integer, optional),
    intIpAddress (string, optional),
    lastAuditDate (integer, optional),
    lastLoggedInUser (string, optional),
    lastReboot (integer, optional),
    lastSeen (integer, optional),
    online (boolean, optional),
    operatingSystem (string, optional),
    patchManagement (PatchManagement, optional),
    portalUrl (string, optional),
    rebootRequired (boolean, optional),
    siteId (integer, optional),
    siteName (string, optional),
    siteUid (string, optional),
    snmpEnabled (boolean, optional),
    softwareStatus (string, optional),
    suspended (boolean, optional),
    udf (Udf, optional),
    uid (string, optional),
    warrantyDate (string, optional)
    }
    PaginationData {
    count (integer, optional),
    nextPageUrl (string, optional),
    prevPageUrl (string, optional)
    }
    Antivirus {
    antivirusProduct (string, optional),
    antivirusStatus (string, optional) = ['RunningAndUpToDate', 'RunningAndNotUpToDate', 'NotRunning', 'NotDetected']
    }
    DevicesType {
    category (string, optional),
    type (string, optional)
    }
    PatchManagement {
    patchStatus (string, optional) = ['NoPolicy', 'NoData', 'RebootRequired', 'InstallError', 'ApprovedPending', 'FullyPatched'],
    patchesApprovedPending (integer, optional),
    patchesInstalled (integer, optional),
    patchesNotApproved (integer, optional)
    }
    Udf {
    udf1 (string, optional),
    udf10 (string, optional),
    udf11 (string, optional),
    udf12 (string, optional),
    udf13 (string, optional),
    udf14 (string, optional),
    udf15 (string, optional),
    udf16 (string, optional),
    udf17 (string, optional),
    udf18 (string, optional),
    udf19 (string, optional),
    udf2 (string, optional),
    udf20 (string, optional),
    udf21 (string, optional),
    udf22 (string, optional),
    udf23 (string, optional),
    udf24 (string, optional),
    udf25 (string, optional),
    udf26 (string, optional),
    udf27 (string, optional),
    udf28 (string, optional),
    udf29 (string, optional),
    udf3 (string, optional),
    udf30 (string, optional),
    udf4 (string, optional),
    udf5 (string, optional),
    udf6 (string, optional),
    udf7 (string, optional),
    udf8 (string, optional),
    udf9 (string, optional)
    }
 
    #>


    # Declare Variables
    $apiMethod = 'GET'
    $maxPage = 50
    $nextPageUrl = $null
    $page = 0
    $Results = @()

    do {
        $Response = New-ApiRequest -apiMethod $apiMethod -apiRequest "/v2/account/devices?max=$maxPage&page=$page" | ConvertFrom-Json
        if ($Response) {
            $nextPageUrl = $Response.pageDetails.nextPageUrl
            $Results += $Response.devices
            $page++
        }
    }
    until ($nextPageUrl -eq $null)

    # Return all account devices
    return $Results
}