PowerShell: Get Domain or Workgroup

Need to check whether a machine is joined to a domain or just a workgroup - for network configuration audits or troubleshooting authentication issues? This one-liner pulls it straight from the system.

Prerequisites:

  • Privileges: None
  • Module: Built-in, no import needed

Quick Command:

Get-CimInstance -ClassName Win32_ComputerSystem | Select-Object Domain, PartOfDomain, Workgroup

Example Output:

Domain       PartOfDomain Workgroup
------       ------------ ---------
corp.local           True
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.

How It Works:

  • Get-CimInstance -ClassName Win32_ComputerSystem queries the same class used earlier for hostname lookups - it also holds domain/workgroup membership info.
  • Domain shows the domain name if the machine is domain-joined, or the workgroup name if it isn't.
  • PartOfDomain gives a direct True/False answer to whether the machine is actually joined to a domain (as opposed to just being in a workgroup with the same displayed name).
  • Workgroup is populated only when the machine is not domain-joined - on a domain-joined machine, this typically shows blank, since Domain already covers that case.