Use net ads testjoin
:
# net ads testjoin -kJoin is OK
→ This box is joined. Now remove it from the domain and testjoin
returns -1:
# net ads leave -kDeleted account for 'DEADBEEF' in realm 'EXAMPLE.COM'# net ads testjoin -kJoin to domain is not valid: NT code 0xfffffff6# echo $?255