Just a quick post, as I recently had the need to do this in an Azure environment, where I needed to confirm that computers had joined an Azure AD Domain services domain. I was looking for a quick and convenient way to confirm that the computer had joined the domain correctly – but without connecting to the network that the virtual machine was deployed to. I was able to achieve this using the Azure ‘Run Command’ virtual machine feature, and the following Powershell code.
To determine whether a computer is a domain member you can run:
(Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain
If this returns a value of ‘True’, then the computer has been joined to a domain successfully. If it returns a value of ‘False’ then it is not a domain member. In this case the following Powershell can be used to confirm that the computer is a member of a workgroup instead:
(Get-WmiObject -Class Win32_ComputerSystem).Workgroup