Powershell Tip #63: Check if a computer is member of a domain or workgroup

By | November 10, 2015

Tip: You can check if a computer is a member of a domain or a workgroup.

Workgroup

PartOfDomainFalsePowerShellWorkgroup

Domain

PartOfDomainTruePowerShellDomain

MSDN:
PartOfDomain property
Win32_ComputerSystem class Class


previous-buttonnext-button

4 thoughts on “Powershell Tip #63: Check if a computer is member of a domain or workgroup

  1. Pingback: Powershell Tip #62: Concatenate arrays | Powershell Guru

  2. Pingback: Powershell Tip #64: Enable or Disable the Windows Firewall | Powershell Guru

  3. Gabriel Martinez

    Hi,

    Unfortunatelly you have no way of checking if it’s an actual domain or not.

    Example (this is a computer in the Workgroup test.local):

    PS C:\Users\Administrator> Get-WmiObject -Class Win32_ComputerSystem

    Domain : TEST.LOCAL
    Manufacturer : Microsoft Corporation
    Model : Virtual Machine
    Name : WIN-2K8R2-01
    PrimaryOwnerName : Windows User
    TotalPhysicalMemory : 1073274880

    Cheers

    Reply
    1. Steve Renard Post author

      Hi Gabriel,

      You can use the PartOfDomain boolean property from the Win32_ComputerSystem class.
      (Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain

      Regards,

      Steve

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *