San Tran

an IT System Engineer

PowerShell, SolarWinds

DCLocator Health Monitor in SolarWinds

I use this PowerShell script for DCLocator health monitor in SolarWinds.

$domain = (Get-ADDomain).DNSRoot
$nltest = nltest /dsgetdc:$domain

if($nltest -eq $null){
    $stat = 1
    $msg = "DCLocator is unable to find a suitable domain controller"
}
else{
    if($nltest[$nltest.Length -1] -eq 'The command completed successfully'){
        $stat = 0
        $msg = "DCLocator is functioning correctly"
    }
    else{
        $stat = 1
        $msg = "DCLocator is unable to find a suitable domain controller"
    }
}
#>
Write-Host "Statistic: $stat"
Write-Host "Message: $msg"