Public/Get-DattoActivityLog.ps1

function Get-DattoActivityLog {
<#
.SYNOPSIS
Returns filtered Datto activity logs ordered by date.
.DESCRIPTION
Implements GET /v1/report/activity-log. Target values are encoded as the documented comma-separated targetType:targetId tuples.
.PARAMETER ClientName
A client-name partial or prefix match.
.PARAMETER Since
The number of time units up to now for which to return logs.
.PARAMETER SinceUnits
Days, hours, or minutes.
.PARAMETER Target
One or more targetType:targetId values.
.PARAMETER TargetType
The target type to filter, such as bcdr-device.
.PARAMETER User
A username partial or prefix match.
.PARAMETER Page
The one-based API page number.
.PARAMETER PerPage
The number of records requested per page.
.PARAMETER All
Retrieves every available page.
.PARAMETER RawResponse
Returns the response envelope.
.PARAMETER Connection
A connection object, name, or ID.
.EXAMPLE
Get-DattoActivityLog -Since 24 -SinceUnits hours -All
.EXAMPLE
Get-DattoActivityLog -TargetType 'bcdr-device' -Target 'bcdr-device:ABC123ABC1'
#>

    [CmdletBinding()]
    param(
        [Parameter()][string]$ClientName,
        [Parameter()][ValidateRange(0, [int]::MaxValue)][int]$Since = 1,
        [Parameter()][ValidateSet('days', 'hours', 'minutes')][string]$SinceUnits = 'days',
        [Parameter()][string[]]$Target,
        [Parameter()][string]$TargetType,
        [Parameter()][string]$User,
        [Parameter()][ValidateRange(1, [int]::MaxValue)][int]$Page = 1,
        [Parameter()][ValidateRange(1, [int]::MaxValue)][int]$PerPage = 25,
        [Parameter()][switch]$All,
        [Parameter()][switch]$RawResponse,
        [Parameter()][AllowNull()][object]$Connection
    )
    $query = @{ _page = $Page; _perPage = $PerPage; since = $Since; sinceUnits = $SinceUnits }
    if ($PSBoundParameters.ContainsKey('ClientName')) { $query['clientName'] = $ClientName }
    if ($PSBoundParameters.ContainsKey('Target')) { $query['target'] = $Target }
    if ($PSBoundParameters.ContainsKey('TargetType')) { $query['targetType'] = $TargetType }
    if ($PSBoundParameters.ContainsKey('User')) { $query['user'] = $User }
    Invoke-DattoApiRequest -Path '/v1/report/activity-log' -Query $query -All:$All -ResultProperty 'items' -RawResponse:$RawResponse -Connection $Connection
}