_DOMAINMEMBER — Returns 1 if the computer is a member of a domain, or 0 otherwise.

Syntax:
%_DOMAINMEMBER


if %_domainmember == 1 echo Already joined to a domain!