Private/Get-DCLiveMetrics.ps1

function Get-DCLiveMetrics {
    param([string]$Server)

    try {
        $cpu = (Get-Counter -ComputerName $Server '\Processor(_Total)\% Processor Time').CounterSamples[0].CookedValue
        $cpu = [math]::Round($cpu, 1)
    }
    catch { $cpu = "n/a" }

    try {
        $sw = [System.Diagnostics.Stopwatch]::StartNew()
        $d = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$Server/RootDSE")
        $null = $d.Properties["defaultNamingContext"].Value
        $sw.Stop()
        $lat = $sw.ElapsedMilliseconds
    }
    catch { $lat = "n/a" }

    [pscustomobject]@{
        CPU  = $cpu
        LDAP = $lat
    }
}