# Discovery

# path to the directory that TNS_ADMIN should point towards
# Make sure its the same in both the remediation and discovery scripts
$value = "\\ccx.carecentrix.com\public\oracle"

try {

    # create the TNS_ADMIN directory if it doesn't exist, no need to use a remediation to do that
    if ( (Test-Path -Path $value -ErrorAction stop) -eq $false ) {
        Write-Host "$value directory missing"
        exit 1
    }

    # check the TNS_ADMIN environmental variable
    $TNS_ADMINVar = [System.Environment]::GetEnvironmentVariable('TNS_ADMIN', 'Machine')
    if ($TNS_ADMINVar -ne $value) {
        Write-Host "failure, TNS_ADMIN is set to $TNS_ADMINVar"
        exit 1
    }

    Write-Host "TNS_ADMIN Variables set correctly"
    exit 0

}
catch {
    $errMsg = $_.Exception.Message
    Write-Host $errMsg
    exit 1 
}