Check if Device is Joined to a Domain

Abstract: Verify if a Windows device is joined to an Active Directory domain using PowerShell and the Win32_ComputerSystem WMI class.

Created: 2026-09-04 by

To verify if a Windows device is joined to an Active Directory domain, query the JoinType property of the Win32_ComputerSystem WMI class using PowerShell. A value of 1 indicates a workgroup, while 2 confirms a domain join. This method provides a reliable, scriptable way to determine the computer's authentication context without relying on network connectivity to domain controllers.

Understanding Domain Join States

Before diving into the code, it is crucial to understand what the system reports regarding its membership status. The Windows operating system tracks the type of account under which the computer exists in two primary categories: local workgroup and Active Directory domain. The Win32_ComputerSystem WMI provider exposes this information through the PartOfDomain boolean property and the JoinType integer property. While PartOfDomain simply returns true or false, JoinType offers more granular detail. Specifically, a JoinType of 2 signifies that the machine is joined to a domain. Other values might indicate pending joins or other states, but for most administrative checks, distinguishing between 1 (workgroup) and 2 (domain) is sufficient. This distinction is vital for security policies, group policy application, and remote management tools that behave differently based on whether the machine trusts a domain authority. For instance, you may need to run scripts that only execute on domain-joined machines to ensure they can access network resources via Kerberos authentication. If you are managing file operations alongside these checks, understanding how to handle paths correctly is also important, as discussed in our guide on Powershell Script to Move Files: A Comprehensive Guide.

The PowerShell Diagnostic Script

The most robust way to check this status is by querying the WMI object directly. This approach works across various versions of Windows, including Windows 10, Windows 11, and Windows Server editions. Below is the standard script used for this verification.
$ComputerName = $env:COMPUTERNAME
$OSInfo = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $ComputerName

if ($OSInfo.PartOfDomain) {
    Write-Host "Device is joined to the domain: $($OSInfo.Domain)"
} else {
    Write-Host "Device is in a Workgroup"
}
This script retrieves the computer system information locally. It checks the PartOfDomain property. If true, it prints the domain name stored in the Domain property. If false, it confirms the device is not part of a domain. For administrators who prefer using the modern CIM cmdlets instead of the legacy Get-WmiObject, the logic remains identical. You would replace Get-WmiObject with Get-CimInstance. Both methods return the same data structure, ensuring consistency in your automation pipelines.

Handling Remote Checks

You can extend this script to check remote machines by passing a target hostname to the -ComputerName parameter. However, note that remote WMI/CIM queries require appropriate permissions and firewall rules (specifically ICMP and RPC ports) to be open on the target machine. If you encounter issues running scripts remotely or via scheduled tasks, refer to our troubleshooting article on Powershell Script Not Running in Task Scheduler: A Troubleshooting Guide for common permission and execution policy pitfalls.

Alternative Methods

While PowerShell is the preferred method for automation, there are alternative ways to check domain status manually.

Using System Properties

You can view the domain status through the graphical interface. Right-click the Start button, select System, and look for the "Workgroup" or "Domain" label next to the computer name. Alternatively, press Win + R, type sysdm.cpl, and open the System Properties dialog. Under the General tab, the full domain name will be displayed if joined.

Command Prompt Check

For quick command-line verification without scripting, use the systeminfo command. Look for the line labeled "Domain" in the output. If the device is in a workgroup, this field typically displays the workgroup name rather than a DNS domain suffix.

Common Pitfalls and Edge Cases

When automating these checks, be aware of transient states. If a device is currently in the process of joining or leaving a domain, the JoinType might reflect an intermediate state. Additionally, cached credentials do not change the JoinType; a machine that has been offline for months still reports its original join status until it reconnects and processes policy updates. If you are packaging scripts for distribution, you might consider combining your PowerShell logic with executable wrappers for broader compatibility. See our tutorial on Combining PS1 and EXE Files into One Package for details on creating self-contained deployment units.

Frequently Asked Questions

Why does PartOfDomain return true even when I am offline?

The PartOfDomain property reflects the configuration stored in the local registry, not real-time connectivity. A machine remains technically "joined" to a domain even if it cannot reach a domain controller, provided the join was successful previously. Always verify network connectivity separately if you need to confirm active trust relationships.

Can I use this script to detect Azure AD joined devices?

No, the Win32_ComputerSystem class primarily reports traditional Active Directory domain memberships. For Azure AD (Entra ID) joined devices, you should query the AzureADJoined property from the Win32_OperatingSystem class or use Microsoft Graph API endpoints specifically designed for cloud identity management.

What is the difference between JoinType 1 and 2?

A JoinType of 1 indicates the computer is part of a local workgroup, meaning it authenticates against local SAM accounts. A value of 2 indicates the computer is joined to an Active Directory domain, allowing it to authenticate against centralized domain controllers and apply Group Policies.

How do I fix a false positive where a workgroup machine shows as joined?

False positives are rare with the WMI method. If you suspect incorrect data, reset the network stack and restart the Netlogon service. Ensure that the machine has not been improperly configured via Group Policy to report fake domain names. Rebooting the machine usually forces a refresh of the system properties cache.

Does this check work for Windows Server Core installations?

Yes, because it relies on WMI/CIM providers which are present in all Windows Server editions, including Server Core. You can run this script via PowerShell Remoting (Enter-PSSession) on headless servers without any GUI components installed.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More