how to check if machine is domain controller?
Using the DomainRole property of the ComputerSystem class is a useful and fast way to check whether a Server Core installation of Windows Server is a Domain Controller, whether it's domain-joined and whether it holds the PDCe FSMO role.