local check Windows active logins output for "not active"

110 views Asked by At

I've got a little local check runnig to see if someone is logged in, in case before I connect via RDP etc.

This works fine if someone is logged in:

@echo off
for /F  %%A in ('"query user | find "Aktiv""') DO (
echo 0 logins-aktiv - Aktiv: %%A, Domain: %USERDOMAIN%, Host: %COMPUTERNAME%, Check: %date% %time%
)

CheckMK: Login active - Screenshot

But if no one is logged CheckMK tells me "Item not found in monitoring data". In that case I would like to have a breakout and a green OK with text like "nicht aktiv". CheckMK: Login not active - Screenshot

I tried some IF/ELSE or IF NOT. But I'm too new to this and can't help myself. My idea is, if there's no input from %%A to jump to "echo 0 logins-aktiv - nicht aktiv" as a print out.

It's a picky thing I know, but I can't help me to fix it, because I don't find the right commands for that. I would like to understand and learn it.

Do you have any idea? Thanks a lot.

0

There are 0 answers