Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > Using CSVDE and appending to the CSV file

Reply
Thread Tools Display Modes

Using CSVDE and appending to the CSV file

 
 
Howard Goldstein
Guest
Posts: n/a

 
      03-10-2010
Hi I've got a question concerning CSVDE and the output file it creates.

I was given a list of over three thousand users, I needed to get the first
and last name, samaccountname, and the office information from each account.

I may be going about this the wrong way, but I'm not a scripter so I don't
know how to do this with vbscript.

Using Excel and DSQuery, I was able to put together a file where I ran
dsquery against all of the users in the list I was given. This gave me the
full common name of each user.

Then using this list and excel, I put together a file where using CSVDE, I
was able to query AD for each user listing the above mentioned attributes as
output data.

The problem is, when I run the first query, it outputs the data to the
output file I have listed in the CSVDE query.

When I run the second query, I want to use the same output file and have it
append the information of the second user. I want to do this for all three
thousand users so when it's done, I'll have one file with all the information
for all the users.

Unfortunately, when I run the second query, the file I created in the first
query is overwritten by the information from the second query. So if I were
to run this command all the way through, it would query for three thousand
users, but it would only list the information for the last user queried.

Is there a way I can get it to append, or perhaps there is an easier way for
me to approach this?
Thanks

 
Reply With Quote
 
 
 
 
Al Dunbar
Guest
Posts: n/a

 
      03-11-2010


"Howard Goldstein" <> wrote in
message news:798F372B-59D9-438C-87EE-...
> Hi I've got a question concerning CSVDE and the output file it creates.
>
> I was given a list of over three thousand users, I needed to get the first
> and last name, samaccountname, and the office information from each
> account.
>
> I may be going about this the wrong way, but I'm not a scripter so I don't
> know how to do this with vbscript.
>
> Using Excel and DSQuery, I was able to put together a file where I ran
> dsquery against all of the users in the list I was given. This gave me
> the
> full common name of each user.
>
> Then using this list and excel, I put together a file where using CSVDE, I
> was able to query AD for each user listing the above mentioned attributes
> as
> output data.
>
> The problem is, when I run the first query, it outputs the data to the
> output file I have listed in the CSVDE query.
>
> When I run the second query, I want to use the same output file and have
> it
> append the information of the second user. I want to do this for all
> three
> thousand users so when it's done, I'll have one file with all the
> information
> for all the users.


you could do the output to a temp file and then append it to another file...

> Unfortunately, when I run the second query, the file I created in the
> first
> query is overwritten by the information from the second query. So if I
> were
> to run this command all the way through, it would query for three thousand
> users, but it would only list the information for the last user queried.
>
> Is there a way I can get it to append, or perhaps there is an easier way
> for
> me to approach this?


I would tend to avoid dsquery and run csvde against the domain to list those
attributes for all accounts. If there are way more accounts than the ones I
was interested in, i'd consider the following possible alternatives:

- a batch file that would read through the csvde output file looking for the
three-thousand of interest, and write their records to a separate file

- a vbscript that would read through the account list file, make ADSI calls
to get the attributes of interest, and write that to an output file.

- if there were an attribute available for your use, you might be able to
use dsquery and dsput to store a special token there, and then do a move
complex csvde query of all accounts having that value in that attribute.

/Al


 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59