Win32_NTDomain

The Win32_NTDomain WMI class represents a Windows domain.

The Win32_NTDomain WMI class represents a Windows domain.

Methods

Win32_NTDomain has no methods.

Properties

Win32_NTDomain returns 27 properties:

'Caption','ClientSiteName','CreationClassName','DcSiteName','Description',
'DNSForestName','DomainControllerAddress','DomainControllerAddressType','DomainControllerName',
'DomainGUID','DomainName','DSDirectoryServiceFlag','DSDnsControllerFlag','DSDnsDomainFlag',
'DSDnsForestFlag','DSGlobalCatalogFlag','DSKerberosDistributionCenterFlag',
'DSPrimaryDomainControllerFlag','DSTimeServiceFlag','DSWritableFlag','InstallDate','Name','NameFormat',
'PrimaryOwnerContact','PrimaryOwnerName','Roles','Status'

Unless explicitly marked as writeable, all properties are read-only. Read all properties for all instances:

Get-CimInstance -ClassName Win32_NTDomain -Property *

Most WMI classes return one or more instances.

When Get-CimInstance returns no result, then apparently no instances of class Win32_NTDomain exist. This is normal behavior.

Either the class is not implemented on your system (may be deprecated or due to missing drivers, i.e. CIM_VideoControllerResolution), or there are simply no physical representations of this class currently available (i.e. Win32_TapeDrive).

Caption

STRING

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, Caption

ClientSiteName

STRING

Name of the site where the domain controller is configured. This value can be NULL.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, ClientSiteName

CreationClassName

STRING

Name of the class or subclass used in the creation of an instance. When used with other key properties of the class, this property allows all instances of the class and its subclasses to be uniquely identified.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, CreationClassName

DcSiteName

STRING

Name of the site where the domain controller is located. This value can be NULL.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DcSiteName

Description

STRING

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, Description

DNSForestName

STRING

Name of the root of the DNS tree.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DNSForestName

DomainControllerAddress

STRING

Address of the discovered domain controller.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DomainControllerAddress

DomainControllerAddressType

SINT32

Type of address specified in the DomainControllerAddress property.

DomainControllerAddressType returns a numeric value. To translate it into a meaningful text, use any of the following approaches:

Use a PowerShell Hashtable
$DomainControllerAddressType_map = @{
      1 = 'DS_INET_ADDRESS'
      2 = 'DS_NETBIOS_ADDRESS'
}
Use a switch statement
switch([int]$value)
{
  1          {'DS_INET_ADDRESS'}
  2          {'DS_NETBIOS_ADDRESS'}
  default    {"$value"}
}
Use Enum structure
Enum EnumDomainControllerAddressType
{
  DS_INET_ADDRESS      = 1
  DS_NETBIOS_ADDRESS   = 2
}

Examples

Use $DomainControllerAddressType_map in a calculated property for Select-Object
<# 
  this example uses a hashtable to translate raw numeric values for 
  property "DomainControllerAddressType" to friendly text

  Note: to use other properties than "DomainControllerAddressType", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "DomainControllerAddressType" 
# to translate other properties, use their translation table instead
$DomainControllerAddressType_map = @{
      1 = 'DS_INET_ADDRESS'
      2 = 'DS_NETBIOS_ADDRESS'
}

#endregion define hashtable

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "DomainControllerAddressType", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$DomainControllerAddressType = @{
  Name = 'DomainControllerAddressType'
  Expression = {
    # property is an array, so process all values
    $value = $_.DomainControllerAddressType
    $DomainControllerAddressType_map[[int]$value]
  }  
}
#endregion define calculated property

# retrieve the instances, and output the properties "Caption" and "DomainControllerAddressType". The latter
# is defined by the hashtable in $DomainControllerAddressType: 
Get-CimInstance -Class Win32_NTDomain | Select-Object -Property Caption, $DomainControllerAddressType

# ...or dump content of property DomainControllerAddressType:
$friendlyValues = Get-CimInstance -Class Win32_NTDomain | 
    Select-Object -Property $DomainControllerAddressType |
    Select-Object -ExpandProperty DomainControllerAddressType

# output values
$friendlyValues

# output values as comma separated list
$friendlyValues -join ', '

# output values as bullet list
$friendlyValues | ForEach-Object { "- $_" }
Use $DomainControllerAddressType_map to directly translate raw values from an instance
<# 
  this example uses a hashtable to manually translate raw numeric values 
  for property "Win32_NTDomain" to friendly text. This approach is ideal when
  there is just one instance to work with.

  Note: to use other properties than "Win32_NTDomain", look up the appropriate 
  translation hashtable for the property you would like to use instead.
#>

#region define hashtable to translate raw values to friendly text

# Please note: this hashtable is specific for property "Win32_NTDomain" 
# to translate other properties, use their translation table instead
$DomainControllerAddressType_map = @{
      1 = 'DS_INET_ADDRESS'
      2 = 'DS_NETBIOS_ADDRESS'
}

#endregion define hashtable

# get one instance:
$instance = Get-CimInstance -Class Win32_NTDomain | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to illustrate
  the number-to-text translation. To process all instances, replace
  "Select-Object -First 1" with a "Foreach-Object" loop, and use
  the iterator variable $_ instead of $instance
#>

# query the property
$rawValue = $instance.DomainControllerAddressType  

# translate raw value to friendly text:
$friendlyName = $DomainControllerAddressType_map[[int]$rawValue]

# output value
$friendlyName
Use a switch statement inside a calculated property for Select-Object
<# 
  this example uses a switch clause to translate raw numeric 
  values for property "DomainControllerAddressType" to friendly text. The switch
  clause is embedded into a calculated property so there is
  no need to refer to external variables for translation.

  Note: to use other properties than "DomainControllerAddressType", look up the appropriate 
  translation switch clause for the property you would like to use instead.
#>

#region define calculated property (to be used with Select-Object)

<#
  a calculated property is defined by a hashtable with keys "Name" and "Expression"
  "Name" defines the name of the property (in this example, it is "DomainControllerAddressType", but you can rename it to anything else)
  "Expression" defines a scriptblock that calculates the content of this property
  in this example, the scriptblock uses the hashtable defined earlier to translate each numeric
  value to its friendly text counterpart:
#>
 
$DomainControllerAddressType = @{
  Name = 'DomainControllerAddressType'
  Expression = {
    # property is an array, so process all values
    $value = $_.DomainControllerAddressType
    
    switch([int]$value)
      {
        1          {'DS_INET_ADDRESS'}
        2          {'DS_NETBIOS_ADDRESS'}
        default    {"$value"}
      }
      
  }  
}
#endregion define calculated property

# retrieve all instances...
Get-CimInstance -ClassName Win32_NTDomain | 
  # ...and output properties "Caption" and "DomainControllerAddressType". The latter is defined
  # by the hashtable in $DomainControllerAddressType:
  Select-Object -Property Caption, $DomainControllerAddressType
Use the Enum from above to auto-translate the code values
<# 
  this example translates raw values by means of type conversion
  the friendly names are defined as enumeration using the
  keyword "enum" (PowerShell 5 or better)
  
  The raw value(s) are translated to friendly text by 
  simply converting them into the enum type.
  
  Note: to use other properties than "Win32_NTDomain", look up the appropriate 
  enum definition for the property you would like to use instead.
#>


#region define enum with value-to-text translation:
Enum EnumDomainControllerAddressType
{
  DS_INET_ADDRESS      = 1
  DS_NETBIOS_ADDRESS   = 2
}

#endregion define enum

# get one instance:
$instance = Get-CimInstance -Class Win32_NTDomain | Select-Object -First 1

<#
  IMPORTANT: this example processes only one instance to focus on
  the number-to-text type conversion. 
  
  To process all instances, replace   "Select-Object -First 1" 
  with a "Foreach-Object" loop, and use the iterator variable 
  $_ instead of $instance
#>

# query the property:
$rawValue = $instance.DomainControllerAddressType

#region using strict type conversion

<#
  Note: strict type conversion fails if the raw value is 
  not defined by the enum. So if the list of allowable values
  was extended and the enum does not match the value,
  an exception is thrown
#>

# convert the property to the enum **DomainControllerAddressType** 
[EnumDomainControllerAddressType]$rawValue 

# get a comma-separated string:
[EnumDomainControllerAddressType]$rawValue -join ',' 
#endregion

#region using operator "-as"

<#
  Note: the operator "-as" accepts values not defined
  by the enum and returns $null instead of throwing
  an exception
#>

$rawValue -as [EnumDomainControllerAddressType]
#endregion

Enums must cover all possible values. If DomainControllerAddressType returns a value that is not defined in the enum, an exception occurs. The exception reports the value that was missing in the enum. To fix, add the missing value to the enum.

DomainControllerName

STRING

Computer name for the discovered domain controller.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DomainControllerName

DomainGUID

STRING

Globally unique identifier (GUID) of the domain controller. This property is 0 (zero) if the domain controller does not have a GUID.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DomainGUID

DomainName

STRING

Name of the domain.

Example: microsoft.com

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DomainName

DSDirectoryServiceFlag

BOOLEAN

If TRUE, the domain controller is a directory service server.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSDirectoryServiceFlag

DSDnsControllerFlag

BOOLEAN

If TRUE, the Domain Controller Name is in DNS format.

Example: www.mynode.com or 135.5.33.19

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSDnsControllerFlag

DSDnsDomainFlag

BOOLEAN

If TRUE, the DomainName value is in DNS format.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSDnsDomainFlag

DSDnsForestFlag

BOOLEAN

If TRUE, the DNSForestName value is in Domain Name System (DNS) format.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSDnsForestFlag

DSGlobalCatalogFlag

BOOLEAN

If TRUE, the domain controller is a Global Catalog server for the DNSForestName value.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSGlobalCatalogFlag

DSKerberosDistributionCenterFlag

BOOLEAN

If TRUE, the domain controller is a Kerberos Key Distribution Center for the domain.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSKerberosDistributionCenterFlag

DSPrimaryDomainControllerFlag

BOOLEAN

If TRUE, the domain controller is the Primary Domain Controller.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSPrimaryDomainControllerFlag

DSTimeServiceFlag

BOOLEAN

If TRUE, the domain is running the Windows Time service.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSTimeServiceFlag

DSWritableFlag

BOOLEAN

If TRUE, the domain controller hosts a writeable DS or security accounts manager (SAM).

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, DSWritableFlag

InstallDate

DATETIME

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, InstallDate

Name

KEY PROPERTY STRING

Label by which the object is known.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name

NameFormat

STRING

Format to generate the system name using the subclass heuristic.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, NameFormat

PrimaryOwnerContact

STRING

How the primary system owner can be reached (for example, phone number or email address).

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, PrimaryOwnerContact

PrimaryOwnerName

STRING MAX 64 CHAR

Name of the primary system owner.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, PrimaryOwnerName

Roles

WRITEABLE STRING ARRAY

An array of strings that specify the roles the computer system plays in the IT environment. Values are defined by the IT environment in which the computer system resides. For example, for an instance of a networking system, this property might contain the string, “Switch” or “Bridge”.

Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, Roles

Status

STRING

Current status of an object. Various operational and nonoperational statuses can be defined. Available values:

$values = 'Degraded','Error','Lost Comm','No Contact','NonRecover','OK','Pred Fail','Service','Starting','Stopping','Stressed','Unknown'
Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property Name, Status

Examples

List all instances of Win32_NTDomain
Get-CimInstance -ClassName Win32_NTDomain

Learn more about Get-CimInstance and the deprecated Get-WmiObject.

View all properties
Get-CimInstance -ClassName Win32_NTDomain -Property *
View key properties only
Get-CimInstance -ClassName Win32_NTDomain -KeyOnly

Selecting Properties

To select only some properties, pipe the results to Select-Object -Property a,b,c with a comma-separated list of the properties you require. Wildcards are permitted.

Get-CimInstance always returns all properties but only retrieves the ones that you specify. All other properties are empty but still present. That’s why you need to pipe the results into Select-Object if you want to limit the visible properties, i.e. for reporting.

Selecting Properties

The code below lists all available properties. Remove the ones you do not need:

$properties = 'Caption',
              'ClientSiteName',
              'CreationClassName',
              'DcSiteName',
              'Description',
              'DNSForestName',
              'DomainControllerAddress',
              'DomainControllerAddressType',
              'DomainControllerName',
              'DomainGUID',
              'DomainName',
              'DSDirectoryServiceFlag',
              'DSDnsControllerFlag',
              'DSDnsDomainFlag',
              'DSDnsForestFlag',
              'DSGlobalCatalogFlag',
              'DSKerberosDistributionCenterFlag',
              'DSPrimaryDomainControllerFlag',
              'DSTimeServiceFlag',
              'DSWritableFlag',
              'InstallDate',
              'Name',
              'NameFormat',
              'PrimaryOwnerContact',
              'PrimaryOwnerName',
              'Roles',
              'Status'
Get-CimInstance -ClassName Win32_NTDomain | Select-Object -Property $properties
Limiting Network Bandwidth

If you work remotely, it makes sense to limit network bandwidth by filtering the properties on the server side, too:

Get-CimInstance -Class Win32_NTDomain -Property $property | 
Select-Object -Property $property

Selecting Instances

To select some instances, use Get-CimInstance and a WMI Query. The wildcard character in WMI Queries is % (and not “*”).

The parameter -Filter runs a simple query.

Listing all instances where the property Caption starts with “A”
Get-CimInstance -Class Win32_NTDomain -Filter 'Caption LIKE "a%"' 
Using a WQL Query

The parameter -Query uses a query similar to SQL and combines the parameters -Filter and -Property. This returns all instances where the property Caption starts with “A”, and returns the properties specified:

Get-CimInstance -Query "SELECT NameFormat, Name, Description, DomainControllerAddressType FROM Win32_NTDomain WHERE Caption LIKE 'a%'"

Any property you did not specify is still present but empty. You might need to use Select-Object to remove all unwanted properties:

Get-CimInstance -Query "SELECT NameFormat, Name, Description, DomainControllerAddressType FROM Win32_NTDomain WHERE Caption LIKE 'a%'" | Select-Object -Property NameFormat, Name, Description, DomainControllerAddressType

Accessing Remote Computers

To access remote systems, you need to have proper permissions. User the parameter -ComputerName to access one or more remote systems.

Authenticating as Current User
# one or more computer names or IP addresses:
$list = 'server1', 'server2'

# authenticate with your current identity:
$result = Get-CimInstance -ClassName Win32_NTDomain -ComputerName $list 
$result
Authenticating as Different User

Use a CIMSession object to authenticate with a new identity:

# one or more computer names or IP addresses:
$list = 'server1', 'server2'

# authenticate with a different identity:
$cred = Get-Credential -Message 'Authenticate to retrieve WMI information:'
$session = New-CimSession -ComputerName $list -Credential $cred

$result = Get-CimInstance Win32_NTDomain -CimSession $session

# remove the session after use (if you do not plan to re-use it later)
Remove-CimSession -CimSession $session

$result

Learn more about accessing remote computers.

Requirements

To use Win32_NTDomain, the following requirements apply:

PowerShell

Get-CimInstance was introduced with PowerShell Version 3.0, which in turn was introduced on clients with Windows 8 and on servers with Windows Server 2012.

If necessary, update Windows PowerShell to Windows PowerShell 5.1, or install PowerShell 7 side-by-side.

Operating System

Win32_NTDomain was introduced on clients with Windows Vista and on servers with Windows Server 2008.

Namespace

Win32_NTDomain lives in the Namespace Root/CIMV2. This is the default namespace. There is no need to use the -Namespace parameter in Get-CimInstance.

Implementation

Win32_NTDomain is implemented in Wmipcima.dll and defined in Wmipcima.mof. Both files are located in the folder C:\Windows\system32\wbem:

explorer $env:windir\system32\wbem
notepad $env:windir\system32\wbem\Wmipcima.mof