backlog/Test-CmDiscoveryExclusions.ps1

function Test-CmDiscoveryExclusions {
    [CmdletBinding()]
    param (
        [parameter()][string] $TestName = "Discovery Methods with Exclusions",
        [parameter()][string] $TestGroup = "configuration",
        [parameter()][string] $TestCategory = "CM",
        [parameter()][string] $Description = "Warn about exclusions and possible missing resources",
        [parameter()][hashtable] $ScriptParams
    )
    try {
        $startTime = (Get-Date)
        #[int]$Setting = Get-CmHealthDefaultValue -KeySet "keygroup:keyname" -DataSet $CmHealthConfig
        [System.Collections.Generic.List[PSObject]]$tempdata = @() # for detailed test output to return if needed
        $stat   = "PASS" # do not change this
        $except = "WARNING" # or "FAIL"
        $msg    = "No issues found" # do not change this either
        <#
        =======================================================
        COMMENT: EXAMPLE FOR SQL QUERY RELATED TESTS... DELETE THIS BLOCK IF NOT USED
        =======================================================
        $query = ""
        $res = Get-CmSqlQueryResult -Query $query -Params $ScriptParams
        if ($null -ne $res -and $res.Count -gt 0) {
            $stat = $except
            $msg = "$($res.Count) items found"
            #$res | Foreach-Object {$tempdata.Add( [pscustomobject]@{Name=$_.Name} )}
        }
        =======================================================
        #>

    }
    catch {
        $stat = 'ERROR'
        $msg = $_.Exception.Message -join ';'
    }
    finally {
        Write-Output $([pscustomobject]@{
            Computer    = $ScriptParams.ComputerName
            TestName    = $TestName
            TestGroup   = $TestGroup
            TestData    = $tempdata
            Description = $Description
            Status      = $stat
            Message     = $msg
            RunTime     = $(Get-RunTime -BaseTime $startTime)
            Credential  = $(if($ScriptParams.Credential){$($ScriptParams.Credential).UserName} else { $env:USERNAME })
        })
    }
}