could be better

here is the first problem:

###########################
$status = 0;
$desc = “”;

test-activesyncconnectivity | ForEach-Object {
[snippet]
elseif ($status -eq “0”) {
Write-Host “OK: ActiveSync Connectivity OK”
###########################

if you have an error on “test-activesyncconnectivity” the status will be “OK” at the end.

i would do the following as a fast fix:

###############
$status = 2; # 2 = critical
$desc = “”;

test-activesyncconnectivity | ForEach-Object {
if($_.Result -like “Success”) {
$status = 0;
###############

So you would get a “critical” output at the end if you have a problem at “test-activesyncconnectivity”.

fast hint for other languages:

######################
elseif($_.Result -like “Failure”) {
######################

in german it would be:

######################
elseif($_.Result -like “Erfolgreich”) {
######################

greetz