Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specify domain controller with get-aduser in powershell

Get-ADUser -identity $ntaccount1 -properties name, samaccountname, mail, enabled, passwordlastset

Is it possible, when looking up the user account information in powershell, to specify a domain controller to use? We have some DC's that get the data faster than others.

like image 514
Aaron Avatar asked Dec 08 '14 16:12

Aaron


2 Answers

From Get-Help Get-ADUser -Parameter *

-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.
    Domain name values:
      Fully qualified domain name
        Examples: corp.contoso.com
      NetBIOS name
        Example: CORP

    Directory server values:
      Fully qualified directory server name
        Example: corp-DC12.corp.contoso.com
      NetBIOS name
        Example: corp-DC12
      Fully qualified directory server name and port
        Example: corp-DC12.corp.contoso.com:3268

    The default value for the Server parameter is determined by one of the following methods in the order that they are listed:
      -By using Server value from objects passed through the pipeline.
      -By using the server information associated with the Active Directory PowerShell provider drive, when running under that drive.
      -By using the domain of the computer running Powershell. 

    The following example shows how to specify a full qualified domain name as the parameter value.
      -Server "corp.contoso.com"

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false
like image 183
mjolinor Avatar answered Sep 23 '22 10:09

mjolinor


This is what i use:

Get-ADUser -server dcservername.domain.local -identity username
like image 20
sfx Avatar answered Sep 22 '22 10:09

sfx