private/Write-VexaTotals.ps1

function Write-VexaTotals {
    param (
        [string[]] $Test,
        [hashtable] $Filter
    )
    $PrevInventory = $Global:VexaData.Inventories.Prev

    if ($Filter.Datacenter) {
        $PrevInventory.Datacenter = $PrevInventory.Datacenter.Where({$_.Name -in $Filter.Datacenter})
        $PrevInventory.ClusterComputeResource = $PrevInventory.ClusterComputeResource.Where({
            $_.Id -in $PrevInventory.Datacenter.Children
        })
        $PrevInventory.HostSystem = $PrevInventory.HostSystem.Where({
            $_.Id -in $PrevInventory.Datacenter.Children
        })
    }

    if ($Filter.ClusterComputeResource) {
        $PrevInventory.ClusterComputeResource = $PrevInventory.ClusterComputeResource.Where({
            $_.Name -in $Filter.ClusterComputeResource})
        $PrevInventory.HostSystem = $PrevInventory.HostSystem.Where({
            $_.Id -in $PrevInventory.ClusterComputeResource.Host
        })
    }

    if ($Filter.HostSystem) {
        $PrevInventory.HostSystem = $PrevInventory.HostSystem.Where({$_.Name -in $Filter.HostSystem})
    }

    if ($Test -match "All|Datacenter") {
        $Datacenters = $PrevInventory.Datacenter.Count
    } else {
        $Datacenters = 0
    }

    if ($Test -match "All|ClusterComputeResource") {
        $Clusters = $PrevInventory.ClusterComputeResource.Count
    } else {
        $Clusters = 0
    }

    if ($Test -match "All|HostSystem") {
        $Hosts = $PrevInventory.HostSystem.Count
    } else {
        $Hosts = 0
    }

    $Output = @"
Tested Datacenters: $Datacenters, Clusters: $Clusters, Hosts: $Hosts
"@

    Write-Host -Object $Output -ForegroundColor "DarkGray"
}