Discussion:
dsget - delete header info in output?
(too old to reply)
Pete
2005-07-20 18:58:39 UTC
Permalink
Hello,

Is it possible to output data without the header information when using
dsget?

For example,

Using the command:

dsquery group -name "users" | dsget group -members | dsget user
-display -email

Can I get the data without the words "display" and "email" appearing at
the top of the columns?


And on that note can I also suppress the phrase "dsget succeeded" at
the end of the output?

Thanks,
Pete
Paul Williams [MVP]
2005-07-20 20:15:03 UTC
Permalink
You could run the command using VB Script (WSH), and then perform some basic
string operations on the output so that you miss out the first and last
bits.
--
Paul Williams
Microsoft MVP - Windows Server - Directory Services
http://www.msresource.net | http://forums.msresource.net
Jerold Schulman
2005-07-20 20:26:05 UTC
Permalink
Post by Pete
Hello,
Is it possible to output data without the header information when using
dsget?
For example,
dsquery group -name "users" | dsget group -members | dsget user
-display -email
Can I get the data without the words "display" and "email" appearing at
the top of the columns?
And on that note can I also suppress the phrase "dsget succeeded" at
the end of the output?
Thanks,
Pete
The following is 1 line:

for /f "Tokens=*" %a in ('dsquery group -name "userss"^|dsget group -members^|dsget user -display -email^|Find /V "email"^|find /V "dsget"') do @echo %a
Pete
2005-07-20 20:59:45 UTC
Permalink
Thanks Jerold.

This works perfectly.

My next step is to output this as a CSV. Any advice?
Jerold Schulman
2005-07-21 16:14:48 UTC
Permalink
Post by Pete
Thanks Jerold.
This works perfectly.
My next step is to output this as a CSV. Any advice?
Yes.

See the following in the 'Tips & Tricks' at http://www.jsifaq.com

9306 ยป How can I list the members of a domain group, security or distribution, given the group sAMAccountName (SAMID)?

Then

UsrDNE Users FileName.csv

Where UsrDNE.bat contains:
@echo off
If {%2}=={} @echo Syntax: UsrDNE GroupName CSVFileName&goto :EOF
setlocal ENABLEDELAYEDEXPANSION
set grp=%1
set file=%2
if exist %file% del /q %file%
for /f "Tokens=1* Delims=;" %%a in ('SAMIDGrpMbrs %grp%') do (
set UserDN=%%a
set UserDN=!UserDN:"=!
set UserSAMID=%%b
:: From here to the next comment is 1 line
for /f "Tokens=1* Delims=: " %%u in ('dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(distinguishedName=!UserDN!))" -attr displayName mail -L -Limit 0') do (
:: End of 1 line
if /i "%%u" EQU "displayName" set display=%%v
if /i "%%u" EQU "mail" @echo !UserSAMID!,"!UserDN!","!display!","%%v">>%file%
)
)
endlocal

Here is 1 line from the CSV file:

"Jerry","CN=Jerold Schulman,CN=Users,DC=JSIINC,DC=COM","Jerold Schulman","***@JSIINC.COM"
Pete
2005-07-21 21:09:18 UTC
Permalink
Jerry -

Thank you. I appreciate your effort. I'm working on getting it to
work.

Getting "The syntax of the command is incorrect." error on running
UsrDNE.

I need to wrap up for today, but will try again tomorrow.

Thanks again.

Pete

Paul Bergson
2005-07-20 22:10:05 UTC
Permalink
Wow - nice!
--
Paul Bergson MCT, MCSE, MCSA, CNE, CNA, CCA

This posting is provided "AS IS" with no warranties, and confers no rights.
Post by Jerold Schulman
Post by Pete
Hello,
Is it possible to output data without the header information when using
dsget?
For example,
dsquery group -name "users" | dsget group -members | dsget user
-display -email
Can I get the data without the words "display" and "email" appearing at
the top of the columns?
And on that note can I also suppress the phrase "dsget succeeded" at
the end of the output?
Thanks,
Pete
for /f "Tokens=*" %a in ('dsquery group -name "userss"^|dsget
group -members^|dsget user -display -email^|Find /V "email"^|find /V
Loading...