DSGet Command Line Tool for Active Directory 2003

DS built-in tools for Windows Server 2003

DSGet is a logical progression from DSQuery.  The idea is that when DSQuery returns a list of objects, DSGet can interrogate those objects for extra properties such as, description, manager or department.  Naturally this pre-supposes you entered the relevant information in the user’s properties sheet!

Contents for DSGet

 ♦

Introduction to DSGet

My assumption is that you are comfortable with DSQuery, if this is not the case take the time to have a refresher and study DSQuery.

Next a reminder to pay close attention to DS syntax.  In this instance what we need is a pipe symbol ( | ) to join DSQuery with DSGet.  Just to be clear, you type this pipe (|) with the shift key and the key next to the Z.  (A colon : would produce an error).

Example 1 To Check that DSQuery is working

Let build a solid foundation with a DSQuery (Only found on a Windows Server 2003 DC)

dsquery user domainroot -name smith*
or
dsquery user -name smith*

Learning Points

Note 1:  You need a Windows Server 2003 machine.  Perhaps you could remote desktop into such a server?

Note 2:  Feel free to change smith* to one of your users.  Better still, create a test account and start filling in those user properties.

Note 3:  This example is just to build a foundation.  Now let us move on to DSGet.

Example 2 Basic DSGet

We need to interrogate the output for more information.  So we use DSGet to retrieve the description.

dsquery user domainroot -name smith*
or
dsquery user -name smith* | dsget user -dn -desc

Learning Points for DSGet

Note 1:  Master the pipe command | which separates dsquery from dsget.  To create |, Hold down the shift key while pressing the key next to the Z.

Note 2:  Even though dsquery told the operating system it was a user object, dsget still has to invoke user in its section of the command.

Challenge:  See what happens if you omit the -dn.

Guy Recommends:  SolarWinds’ Free Bulk Import ToolFree Download Solarwinds 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. Download your FREE bulk import tool.

If you need more comprehensive software, download a free trial of SAM (Server & Application Monitor)

Example 3 – Which extra properties shall we query?

-display  Display name is different from the user’s description field.  If you haven’t done so already, time to get a user’s properties sheet and start filling in those attribute boxes.

-office  Useful property

-sn This command does not work.  What’s the matter with -sn?  I will tell you what’s wrong; dsget requires -ln instead of -sn and -fn instead of givenName   grrrrrrrrrrrrrrrrrr.  Calm down Guy, go with the flow; think of all these useful switches.

O.K. No more moaning.  DSGet is actually fun and productive.  Guess what information these switches return?

-email, -tel, -mgr, -mobile

Answers: General (tab), email address, telephone number,  Organization (tab), Manager, Telephones (tab), Mobile.

Now find them on the user’s properties sheet.

°

Example 4 – Change the DSget output.

They say the old tricks the best, so let us try exporting the DSGet output not to screen but a text file.  Here we need a different type of pipe command; this time it’s the greater than symbol, for example,  > filename.txt.  So, just tag on > filename.txt to your DS command.  Follow up with:  notepad filename.txt.

dsquery user domainroot -name smith*
or
dsquery user -name smith* | dsget user -fn -ln -mgr > dsget.txt

Learning Points

Note 1: To read the file type, notepad dsget.txt

Note 2: I am impressed by the column format of the output

I would like to leave you with a few more DSGet object that you can interrogate or experiment with.  In addition to user, there are the following DSGet commands : Computer, also Server – meaning DC,  OU, Group, even Site and Subnet.

Note. There are also two commands called partition and quota, however, in the context of DSGet, partition and quota refer to Active Directory, not disk.  For example, the application partition in Active Directory.  Tell the truth, it was a big disappointment that DSGet did not return the disk information, but on reflection I was expecting the impossible.  DSGet partition means Active Directory partition.

Summary – DSGet

As far as DSGet is concerned, I have come from Philistine to champion.  Now I really enjoy the challenge of DSGet and appreciate the way it works hand in glove with DSQuery.  It also reminds of that old truism the more you know the easier it gets.

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    • Free Import CSV Tool

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

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