How to check whether device is unauthorised or not in adb batch script

I'm writing a batch script file for my device to perform simple adb actions. Now I need to check whether my device is detected or not in pc using command adb devices. But if the device is detected in adb devices it can be of two status,

1st if its unauthorized, it will show as xxxxxxxx unauthorized

2nd if its authorized, it will show as xxxxxxxx device

Currently I have written like this:

FOR /f %%A IN ('adb.exe devices') DO SET device=%%A
if "%device%"=="" goto DeviceNotFound else goto RebootBootloader

Now my code can't detect whether its authorized or unauthorized or not. Is there any way to check it? I'm new to batch file scripting. Can someone please help me.

Thanks in advance..