Quick time that I have found quite useful to check if a device is already joined to a domain, something is wrong or even unjoin the device from Azure AD. To check if a device is joined to Azure AD, we can make use of the DsRegCmd tool in the following way:
DsRegCmd /status
To unjoin a device from Azure AD, we have to make use of DsRegCmd in the following way:
dsregcmd /debug /leave
The output we should get from the first command is the following:
References: