Export (0) Print
Expand All
Expand Minimize

Get-ADDomainController

Windows Server 2012 R2 and Windows 8.1

Updated: July 8, 2014

Applies To: Windows 8.1, Windows PowerShell 4.0, Windows Server 2012 R2

Get-ADDomainController

Gets one or more Active Directory domain controllers based on discoverable services criteria, search parameters or by providing a domain controller identifier, such as the NetBIOS name.

Syntax

Parameter Set: Identity
Get-ADDomainController [[-Identity] <ADDomainController> ] [-AuthType <ADAuthType> {Negotiate | Basic} ] [-Credential <PSCredential> ] [-Server <String> ] [ <CommonParameters>]

Parameter Set: DiscoverByService
Get-ADDomainController -Discover [-AuthType <ADAuthType> {Negotiate | Basic} ] [-AvoidSelf] [-DomainName <String> ] [-ForceDiscover] [-MinimumDirectoryServiceVersion <ADMinimumDirectoryServiceVersion> {Windows2000 | Windows2008 | Windows2012 | Windows2012R2} ] [-NextClosestSite] [-Service {ADWS | GlobalCatalog | KDC | PrimaryDC | ReliableTimeService | TimeService}[] ] [-SiteName <String> ] [-Writable] [ <CommonParameters>]

Parameter Set: Filter
Get-ADDomainController -Filter <String> [-AuthType <ADAuthType> {Negotiate | Basic} ] [-Credential <PSCredential> ] [-Server <String> ] [ <CommonParameters>]




Detailed Description

The Get-ADDomainController cmdlet gets the domain controllers specified by the parameters. You can get domain controllers by setting the Identity, Filter or Discover parameters.

The Identity parameter specifies the domain controller to get. You can identify a domain controller by its GUID, IPV4Address, global IPV6Address, or DNS host name. You can also identify a domain controller by the name of the server object that represents the domain controller, the Distinguished Name (DN) of the NTDS settings object or the server object, the GUID of the NTDS settings object or the server object under the configuration partition, or the DN of the computer object that represents the domain controller. You can also set the Identity parameter to a domain controller object variable, such as $<localDomainControllerObject>, or pass a domain controller object through the pipeline to the Identity parameter.

To search for and retrieve more than one domain controller, use the Filter parameter. The Filter parameter uses the PowerShell Expression Language to write query strings for Active Directory. PowerShell Expression Language syntax provides rich type conversion support for value types received by the Filter parameter. For more information about the Filter parameter syntax, type Get-Help about_ActiveDirectory_Filter. You cannot use an LDAP query string with this cmdlet.

To get a domain controller by using the discovery mechanism of DCLocator, use the Discover parameter. You can provide search criteria by setting parameters such as Service, SiteName, DomainName, NextClosestSite, AvoidSelf, and ForceDiscover.

Parameters

-AuthType<ADAuthType>

Specifies the authentication method to use. The acceptable values for this parameter are: 

-- Negotiate or 0
-- Basic or 1

The default authentication method is Negotiate.

A Secure Sockets Layer (SSL) connection is required for the Basic authentication method.


Aliases

none

Required?

false

Position?

named

Default Value

Microsoft.ActiveDirectory.Management.AuthType.Negotiate

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-AvoidSelf

Specifies to not return the current computer as a domain controller. If the current computer is not a domain controller, this parameter is ignored. You can specify this parameter when you want to get the name of another domain controller in the domain.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Credential<PSCredential>

Specifies the user account credentials to use to perform this task. The default credentials are the credentials of the currently logged on user unless the cmdlet is run from an Active Directory PowerShell provider drive. If the cmdlet is run from such a provider drive, the account associated with the drive is the default.

To specify this parameter, you can type a user name, such as User1 or Domain01\User01 or you can specify a PSCredential object. If you specify a user name for this parameter, the cmdlet prompts for a password.

You can also create a PSCredential object by using a script or by using the Get-Credential cmdlet. You can then set the Credential parameter to the PSCredential object.

If the acting credentials do not have directory-level permission to perform the task, Active Directory PowerShell returns a terminating error.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Discover

Specifies to return a discoverable domain controller that meets the conditions specified by the cmdlet parameters.

To get a domain controller by using the discovery mechanism of DCLocator, use the Discover parameter. Along with this parameter, you can provide search criteria by setting parameters such as Service, SiteName, DomainName, NextClosestSite, AvoidSelf, and ForceDiscover.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DomainName<String>

Specifies the domain to search. The cmdlet locates a discoverable domain controller in this domain. Specify the domain by using the NetBIOS name or Fully Qualified Domain Name (FQDN) of the domain.


Aliases

none

Required?

false

Position?

named

Default Value

Name of the domain to which this machine is joined

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Filter<String>

Specifies a query string that retrieves Active Directory objects. This string uses the PowerShell Expression Language syntax. The PowerShell Expression Language syntax provides rich type-conversion support for value types received by the Filter parameter. The syntax uses an in-order representation, which means that the operator is placed between the operand and the value. For more information about the Filter parameter, type Get-Help about_ActiveDirectory_Filter.

Syntax:

The following syntax uses Backus-Naur form to show how to use the PowerShell Expression Language for this parameter.

<filter> ::= "{" <FilterComponentList> "}"

<FilterComponentList> ::= <FilterComponent> | <FilterComponent> <JoinOperator> <FilterComponent> | <NotOperator> <FilterComponent>

<FilterComponent> ::= <attr> <FilterOperator> <value> | "(" <FilterComponent> ")"

<FilterOperator> ::= "-eq" | "-le" | "-ge" | "-ne" | "-lt" | "-gt"| "-approx" | "-bor" | "-band" | "-recursivematch" | "-like" | "-notlike"

<JoinOperator> ::= "-and" | "-or"

<NotOperator> ::= "-not"

<attr> ::= <PropertyName> | <LDAPDisplayName of the attribute>

<value>::= <compare this value with an <attr> by using the specified <FilterOperator>>

For a list of supported types for <value>, type Get-Help about_ActiveDirectory_ObjectModel.

Note: PowerShell wildcards other than *, such as ?, are not supported by the Filter syntax.

Note: To query using LDAP query strings, use the LDAPFilter parameter.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ForceDiscover

Indicates that the cmdlet to clears any cached domain controller information and perform a new discovery. If this parameter is not specified the cmdlet may return cached domain controller information.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Identity<ADDomainController>

Specifies an Active Directory domain controller object by providing one of the following values. The identifier in parentheses is the LDAP display name for the attribute. Unless specified otherwise, these values are for the server object that represents the domain controller. The acceptable values for this parameter are: 

-- A GUID (objectGUID)
-- An IPV4Address
-- A Global IPV6Address
-- A DNS Host Name (dNSHostName)
-- The name of the server object
-- The Distinguished Name of the NTDS Settings object
-- The Distinguished Name of the server object that represents the domain controller
-- The GUID of NTDS settings object under the configuration partition
-- The GUID of server object under the configuration partition
-- The Distinguished Name of the computer object that represents the domain controller

The cmdlet searches the default naming context or partition to find the object. If two or more objects are found, the cmdlet returns a non-terminating error.

This parameter can also get this object through the pipeline or you can set this parameter to an object instance.


Aliases

none

Required?

false

Position?

1

Default Value

none

Accept Pipeline Input?

True (ByValue)

Accept Wildcard Characters?

false

-MinimumDirectoryServiceVersion<ADMinimumDirectoryServiceVersion>

Species the earliest operating system that the domain controller can have so that it is returned by the cmdlet when getting a DC using Discover parameter. The acceptable values for this parameter are: 

-- Windows2000 or 1
-- Windows2008 or 2


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-NextClosestSite

Specifies to return a domain controller in the next closest site when a domain controller is not found in the site that contains the client. The next closest site is the site with the lowest site link cost with respect to the current site. Costs between sites are based on factors such as bandwidth, as well as physical proximity.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Server<String>

Specifies the Active Directory Domain Services instance to connect to, by providing one of the following values for a corresponding domain name or directory server. The service may be any of the following: Active Directory Lightweight Domain Services, Active Directory Domain Services or Active Directory Snapshot instance.

Specify the Active Directory Domain Services instance in one of the following ways:

-- Domain name values:

---- Fully qualified domain name
---- NetBIOS name

-- Directory server values:

---- Fully qualified directory server name
---- NetBIOS name
---- Fully qualified directory server name and port

The default value for this parameter is determined by one of the following methods in the order that they are listed:

-- By using the Server value from objects passed through the pipeline
-- By using the server information associated with the Active Directory Domain ServicesWindows PowerShell provider drive, when the cmdlet runs in that drive
-- By using the domain of the computer running Windows PowerShell


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Service<ADDiscoverableService[]>

Species the types of domain controllers to get. You can specify more than one type by using a comma-separated list. The acceptable values for this parameter are: 

-- PrimaryDC or 1
-- GlobalCatalog or 2
-- KDC or 3
-- TimeService or 4
-- ReliableTimeService or 5
-- ADWS or 6


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SiteName<String>

Specifies the name of a site to search in to find the domain controller. If this parameter is not set, the cmdlet searches for domain controllers in the same site as the client. The name of the site is defined by the Name property of the site object.


Aliases

none

Required?

false

Position?

named

Default Value

Name of the site that the client is in

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Writable

Specifies whether this is a writable domain controller.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters.

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.ActiveDirectory.Management.ADDomainController

    A domain controller object is received by the Identity parameter.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.ActiveDirectory.Management.ADDomainController

    Returns one or more domain controller objects.

    When you use the Discover parameter to get a domain controller, the cmdlet returns a default set of property values for each domain controller.

    When you use the Identity or Filter parameters to get a domain controller, this cmdlet returns all of the properties of the domain controller.

    To view all of the properties for an ADDomainController object, use the following command and replace <domaincontroller> with a domain controller identifier such as a DNS host name.

    Get-ADDomainController <domaincontroller> | Get-Member


Notes

  • The Name and HostName properties of the ADDomainController objects returned by the cmdlet are set according to the following rules:

    -- If the Discover parameter is used, HostName is the Fully Qualified Domain Name of the Domain Controller, and the Name is the NetBIOS name of the Domain Controller. With the Discover parameter, the cmdlet will perform a second DCLocator call, to populate the Name property. This property will not be set, to the NetBIOS name of the Domain Controller, if the WINS service is unavailable.

    -- If the Identity or the Filter parameter is used, HostName is the DNSHostName attribute of the Domain Controller object, and the Name is the Name (RDN) attribute of the Domain Controller object. With the Identity or the Filter parameter, the HostName property will not be set, if the DNSHostName attribute of the Domain Controller object is null.

  • This cmdlet does not work with AD LDS.

  • This cmdlet does not work when targeting a snapshot using the Server parameter.

Examples

-------------------------- EXAMPLE 1 --------------------------

This command gets one available DC in the site specified by the Site parameter. The command uses Discovery.


PS C:\> Get-ADDomainController -Discover -Site "Default-First-Site-Name"

-------------------------- EXAMPLE 2 --------------------------

This command force discovers or finds one available DC in the site specified by the Site parameter.


PS C:\> Get-ADDomainController -Discover -Site "Default-First-Site-Name" -ForceDiscover

-------------------------- EXAMPLE 3 --------------------------

This command gets a global catalog in the current forest using Discovery.


PS C:\> Get-ADDomainController -Discover -Service "GlobalCatalog"

-------------------------- EXAMPLE 4 --------------------------

This command gets a global catalog in the current forest using Discovery.


PS C:\> Get-ADDomainController -Discover -Service 2

-------------------------- EXAMPLE 5 --------------------------

This command gets one available DC in the current domain using Discovery.


PS C:\> Get-ADDomainController -Discover

-------------------------- EXAMPLE 6 --------------------------

This command gets one available DC in a given domain using Discovery.


PS C:\> Get-ADDomainController -Discover -Domain "fabrikam.com"

-------------------------- EXAMPLE 7 --------------------------

This command gets the PDC using Discovery and make sure that is advertising as a time server.


PS C:\> Get-ADDomainController -Discover -Domain "corp.contoso.com" -Service "PrimaryDC","TimeService"

-------------------------- EXAMPLE 8 --------------------------

This command gets a domain controller using its NetBIOS name.


PS C:\> Get-ADDomainController -Identity "PDC-01"

-------------------------- EXAMPLE 9 --------------------------

This command gets a domain controller using its DNS host name, in the domain specified by the Site parameter, specified in Server parameter, and specifying administrator credentials.


PS C:\> Get-ADDomainController -Identity "TK5-CORP-DC-10.fabrikam.com" -Server "fabrikam.com" -Credential "corp\administrator"

-------------------------- EXAMPLE 10 --------------------------

This command get a domain controller using its IP address.


PS C:\> Get-ADDomainController -Identity "168.54.62.57"

-------------------------- EXAMPLE 11 --------------------------

This command gets all global catalogs in the site specified by the Site parameter.


PS C:\> Get-ADDomainController -Filter  { isGlobalCatalog -eq $true -and Site -eq "Default-First-Site-Name" }

-------------------------- EXAMPLE 12 --------------------------

This command gets all ROGCs in the child domain to which the client is connected.


PS C:\> Get-ADDomainController -Server "research.fabrikam.com" -Filter { isGlobalCatalog -eq $true -and isReadOnly -eq $true }

-------------------------- EXAMPLE 13 --------------------------

This command gets the domain controller in the user's current session. This is the domain controller used as a default Server in the context of an AD Provider. Using this cmdlet in this way will let you know which Server is being used by default.


PS C:\> Get-ADDomainController

-------------------------- EXAMPLE 14 --------------------------

This command gets a list of all of the domain controllers for all the domains within a forest.


PS C:\> $allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController -Filter * -Server $_ }

Related topics

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft