Directory Services

Guy recommends :
Free SolarWinds
VM Console

Solarwinds VM Console Free Download

Find out which of your VMs are a waste of space and which VMs need more resources.


DSQuery USer Command Line Tool for Active Directory

DSquery Built-in Tool for Windows Server 2003/8

One of the most useful DS commands is DSQuery User.  If I need to find a user quickly from the command prompt, I call upon DSQuery.

DSQuery User

 ♦

Example 1: DS Query User To Find All Users in the Default Users folder

In this example we just want to search the users folder and list the people accounts in that default container.

dsquery user cn=users,dc=YourDomain,dc=com

Learning Points

Note 1:  The default users' folder is actually a container object called cn=users.  My point is if you try ou=users, the command fails.

Note 2:  I queried users, however dsquery requires the singular user, not userS.  Other objects that you can query are computer (not computers!), group or even contact.

Challenge 1:  Substitute OU=xyz for cn=users, where xyz is the name of your OU.  Unfortunately, cn=users domainroot does not work.

Challenge 2:  Substitute "computer" for "user".

Guy Recommends:  SolarWinds' Free Bulk Import ToolFree Download Bulk Import Tool

Import users from a spreadsheet.  Just provide a list of the users with their fields in the top row, and save as .csv file.  Then launch this FREE utility and match your fields with AD's attributes, click and import the users.  Optionally, you can provide the name of the OU where the new accounts will be born.

There are also two bonus tools in the free download, and all 3 have been approved by Microsoft:

  1. Bulk-import new users into Active Directory.
  2. Seek and zap unwanted user accounts.
  3. Find inactive computers.

Download your FREE bulk import tool.

Example 2:  DSQuery User to Find Everyone Whose Name Begins with Smith*

This DSQuery example shows two ways to filter your output and so home in on what you are looking for.  Let us pretend that we know the user's name but have no idea which OU they are to be found.  Moreover, we are not sure whether their name is spelt Smith, Smithy or Smithye.

dsquery user domainroot -name smith*

or:

dsquery user dc=YourDomain,dc=com -name smith*

or plain:

dsquery user smith*

Learning Points

Note 1:  Remember to type the singular user.

Note 2:  Probably no need to introduce *, you probably realize it's a wildcard.

Note 3:  -name is but one of a family of filters. -desc or -disabled are others.

Guy Recommends: SolarWinds Engineer's Toolset v10Engineer's Toolset v10

This Engineer's Toolset v10 provides a comprehensive console of utilities for troubleshooting computer problems.  Guy says it helps me monitor what's occurring on the network, and each tool teaches me more about how the underlying system operates.

There are so many good gadgets; it's like having free rein of a sweetshop. Thankfully the utilities are displayed logically: monitoring, discovery, diagnostic, and Cisco tools.  Download your fully functional trial copy of the Engineer's Toolset v10

Example 3: DSQuery User - Filter the Output with -o rdn

The purpose of -o rdn is to reduce the output to just the relative distinguished name.  In a nutshell rdn strips away the OU=, DC= part which you may not be interested in.

dsquery user -name smith* -o rdn

Learning Points

Note 1:  o is the letter oh (not a number).  In my minds eye o stands for output.

Note 2:  There is a switch -o dn, but this is not a switch I use. 

Summary - DSQuery User

Knowledge is power.  The DS family in general and DSQuery user in particular, provide handy commands for interrogating Active Directory from the command line.  Next try DSGet.

If you like this page then please share it with your friends

 


See more of the DS family of built-in Active Directory utilities

DSQuery   • DSQuery User   • DSQuery Group

• DSGet - List the properties of an object   • DS Commands   • WSH - Create a user

• DSMod - Modify Active Directory attributes    • DSAdd - Create new accounts

 *


Custom Search

Site Home

Guy Recommends: WMI Monitor and It's Free!Solarwinds WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft operating systems.

Fortunately, SolarWinds have created the Free WMI Monitor so that you can actually see and understand these gems of performance information.  Take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

Author: Guy Thomas Copyright © 1999-2012 Computer Performance LTD All rights reserved.

Please report a broken link, or an error to: