Computing.Net > Forums > Programming > dsquery/dsget For loop help!

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

dsquery/dsget For loop help!

Reply to Message Icon

Name: d4rkcell
Date: May 26, 2009 at 05:28:35 Pacific
OS: Microsoft Windows XP Professional
CPU/Ram: 2.327 GHz / 2013 MB
Product: Dell / OPTIPLEX 755
Subcategory: Batch
Comment:

Hi,

I am stuck, I have constructed the below command.

FOR /F %a IN (C:\file.csv) DO dsquery user -samid "%a" | dsget user -fn –ln >> C:\result.csv

Now what this is meant to do is take the samid's in C:\file.csv and use them in the dsquery and then output the first and last name of the account associated to the samid into C:\result.csv.

This isn't happening and I don't know why.

basically i get errors like this...

C:\>dsquery user -samid "11492" | dsget user -fn -ln 1>>C:\result.csv
dsget failed:Value for `Target object for this command' has incorrect format.

Where if I enter...

dsquery user -samid "11492" | dsget user -fn -ln 1>>C:\result.csv

as its own command it works great!

can someone please help me!?!



Sponsored Link
Ads by Google

Response Number 1
Name: d4rkcell
Date: May 26, 2009 at 06:33:47 Pacific
Reply:

Hi, maybe a bit hasty in posting this but just incase anyone in future has trouble.

I stuck it in a bat file and changed the code slightly

FOR /F %%a IN (C:\file.csv) DO (
dsquery user -samid "%%a" | dsget user -fn -ln -desc >> C:\result.csv
)

this appears to work great, looks a bit messy in excel though, leaves all the desc, fn etc in the output.

easilly stripped with a macro.

Cheers
C


0

Response Number 2
Name: IVO
Date: May 26, 2009 at 08:31:09 Pacific
Reply:

Two infos needed

- Is that statement entered at the prompt or as part of a batch script?

- May you post a sample (e.g. two lines) of the input File.csv?


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: dsquery/dsget For loop help!

C++ - need FOR loop help www.computing.net/answers/programming/c-need-for-loop-help/9209.html

Batch file nested FOR loops help www.computing.net/answers/programming/batch-file-nested-for-loops-help/15196.html

Batch programming for loop help www.computing.net/answers/programming/batch-programming-for-loop-help/18116.html