Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use VMWare snapshots a lot and reverting to an earlier snapshot sometimes drops the computer off the domain controller. I am looking for a PowerShell script that would determine that the workstation is not longer part of a domain and only if it is not add it back to the domain. The Add-Computer part is the easy one, but finding out about the state of the domain association is more tricky. Any ideas are welcome. By the way I looked at WMI Win32_ComputerSystem calls and the Domain and Domain role properties. Would this be the right way to go?


share|improve this question
up vote 0 down vote accepted

I've use Get-WmiObject Win32_NTDomain in the past just to get a list of domains. I've noticed the domainName is null when a workstation isn't part of a domain.

share|improve this answer
Thanks, I will give this a try. – senf Jan 13 '10 at 23:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.