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!
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).
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 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:
-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?
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.
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
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.