Site icon TOSS

Get-ADDomainController

powershell

Get-ADDomainController is accessible with the help of addsadministration module. To install addsadministration on your system please refer to this link.

Synopsis

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.

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 $, 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, see 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 
         Specifies the authentication method to use. Possible values for this parameter include:

    Required?                    false
    Position?                    named
    Default value                Microsoft.ActiveDirectory.Management.AuthType.Negotiate
    Accept pipeline input?       false
    Accept wildcard characters?  false

-AvoidSelf <SwitchParameter>
    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.

    Required?                    false
    Position?                    named
    Default value                
    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.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Discover <SwitchParameter>
    Specifies to return a discoverable domain controller that meets the conditions specified by the cmdlet parameters.

    Required?                    true
    Position?                    named
    Default value                
    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.

    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, see about_ActiveDirectory_Filter.

    Required?                    true
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-ForceDiscover <SwitchParameter>
    Forces the cmdlet to clear any cached domain controller information and perform a new discovery.  If this parameter is not specified the cmdlet  may return cached domain controller information.

    Required?                    false
    Position?                    named
    Default value                
    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.

    Required?                    false
    Position?                    1
    Default value                
    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 switch. Possible values are:

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-NextClosestSite <SwitchParameter>
    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.

    Required?                    false
    Position?                    named
    Default value                
    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.

    Required?                    false
    Position?                    named
    Default value                
    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. Possible values for this parameter are:

    Required?                    false
    Position?                    named
    Default value                
    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.

    Required?                    false
    Position?                    named
    Default value                Name of the site that the client is in
    Accept pipeline input?       false
    Accept wildcard characters?  false

-Writable <SwitchParameter>
    Specifies whether or not this is a writable domain controller.

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

Syntax

Get-ADDomainController [-AuthType <ADAuthType>] [-Credential <PSCredential>] [[-Identity] <ADDomainController>] [-Server <String>] [<CommonParameters>]

Get-ADDomainController [-AuthType <ADAuthType>] [-AvoidSelf] [-Discover] [-DomainName <String>] [-ForceDiscover] [-MinimumDirectoryServiceVersion <ADMinimumDirectoryServiceVersion>] [-NextClosestSite] [-Service <ADDiscoverableService[]>] [-SiteName <String>] [-Writable] [<CommonParameters>]

Get-ADDomainController [-AuthType <ADAuthType>] [-Credential <PSCredential>] -Filter <String> [-Server <String>] [<CommonParameters>]

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

————————– EXAMPLE 1 ————————–
C:\PS>Get-ADDomainController -Discover -Site “Default-First-Site-Name”
Get one available DC in a given site using Discovery.

————————– EXAMPLE 2 ————————–
C:\PS>Get-ADDomainController -Discover -Site “Default-First-Site-Name” -ForceDiscover
Force discover/find one available DC in a given site.

————————– EXAMPLE 3 ————————–
C:\PS>Get-ADDomainController -Discover -Service “GlobalCatalog”
Get a global catalog in the current forest using Discovery.

————————– EXAMPLE 4 ————————–
C:\PS>Get-ADDomainController -Discover -Service 2
Get a global catalog in the current forest using Discovery.

————————– EXAMPLE 5 ————————–
C:\PS>Get-ADDomainController -Discover
Get one available DC in the current domain using Discovery.

————————– EXAMPLE 6 ————————–
C:\PS>Get-ADDomainController -Discover -Domain “TOSSolution.com”
Get one available DC in a given domain using Discovery.

————————– EXAMPLE 7 ————————–
C:\PS>Get-ADDomainController -Discover -Domain “Delhi.TOSSolution.com” -Service “PrimaryDC”,”TimeService”
Get the PDC using Discovery and make sure that is advertising as a time server.

————————– EXAMPLE 8 ————————–
C:\PS>Get-ADDomainController -Identity “PDC-01”
Get a domain controller using its NetBIOS name.

————————– EXAMPLE 9 ————————–
C:\PS>Get-ADDomainController “PDC-01”
Get a domain controller using its NetBIOS name.

————————– EXAMPLE 10 ————————–
C:\PS>Get-ADDomainController -Identity “TK5-Delhi-DC-10. TOSSolution .com” -Server ” TOSSolution .com” -Credential “delhi\administrator”
Get a domain controller using its DNS host name, in a given domain (specified in Server parameter) and specifying administrator credentials.

————————– EXAMPLE 11 ————————–
C:\PS>Get-ADDomainController -Identity “168.54.62.57”
Get a domain controller using its IP address.

————————– EXAMPLE 12 ————————–
C:\PS>Get-ADDomainController -Filter { isGlobalCatalog -eq $true -and Site -eq “Default-First-Site-Name” }
Get all global catalogs in a given site.

————————– EXAMPLE 13 ————————–
C:\PS>Get-ADDomainController -Server “general.TOSSolution.com” -Filter { isGlobalCatalog -eq $true -and isReadOnly -eq $true }
Get all ROGCs in the child domain to which the client is connected.

————————– EXAMPLE 14 ————————–
C:\PS>Get-ADDomainController
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.

————————– EXAMPLE 15 ————————–
C:\PS>$allDCs = (Get-ADForest).Domains | %{ Get-ADDomainController –Filter * -Server $_ }
Gets a list of all of the domain controllers for all the domains within a forest.

You can check the Version, CommandType and Source of this cmdlet by giving below command.

Get-Command Get-ADDomainController

You can also read about
. Add-ADDomainControllerPasswordReplicationPolicy
. Get-ADDomainControllerPasswordReplicationPolicy
. Remove-ADDomainControllerPasswordReplicationPolicy

To know more PowerShell cmdlets(Commands) on addsadministration (Active Directory) click here

Click on this Link for an Single place where you get all the PowerShell cmdlet sorted based on the modules.

You can also refer other blogs on PowerShell at link

You can also refer other blogs on Microsoft at link

And also if you required any technology you want to learn, let us know below we will publish them in our site http://tossolution.com/

Like our page in Facebook and follow us for New technical information.

References are taken from Microsoft

Exit mobile version