examples/Export-SaasSeatReport.ps1

[CmdletBinding()]
param(
    [Parameter()]
    [string]$OutputPath = '.\Datto-SaaS-Seats.csv'
)

$report = foreach ($domain in Get-DattoSaasDomain) {
    foreach ($seat in Get-DattoSaasSeat -SaasCustomerId $domain.saasCustomerId) {
        [pscustomobject]@{
            OrganizationId       = $domain.organizationId
            OrganizationName     = $domain.organizationName
            SaasCustomerId       = $domain.saasCustomerId
            SaasCustomerName     = $domain.saasCustomerName
            Domain               = $domain.domain
            ProductType          = $domain.productType
            RetentionType        = $domain.retentionType
            ExternalSubscriptionId = $domain.externalSubscriptionId
            MainId               = $seat.mainId
            Name                 = $seat.name
            SeatType             = $seat.seatType
            SeatState            = $seat.seatState
            Billable             = $seat.billable
            DateAdded            = $seat.dateAdded
            RemoteId             = $seat.remoteId
        }
    }
}
$report | Export-Csv -LiteralPath $OutputPath -NoTypeInformation -Encoding UTF8
Get-Item -LiteralPath $OutputPath