
try {
    Test-Path -Path "C:\Program Files (x86)\Bit9\Parity Agent"
}
catch {
    Write-Host "Carbon Black App Control Folder Does Not Exist"
    exit 1
}

try {
    Test-Path -Path "C:\Program Files (x86)\Bit9\Parity Agent\DasCLI.exe"
}
catch {
    Write-Host "Carbon Black App Control is not installed"
    exit 1
}

Set-Location "C:\Program Files (x86)\Bit9\Parity Agent"
$CBagentstatus = .\DasCLI.exe status

if (((($CBagentstatus[55]).Split(":")[1])).Trimstart() -like "Healthy") {
    Write-Host "Carbon Black agent is healthy"
    Exit 0
}
else {
    Write-Host "Carbon Black App Control Status is unknown" ((($CBagentstatus[55]).Split(":")[1])).Trimstart()
    exit 1
}
