dsquery/dsget For loop help!

Dell / OPTIPLEX 755
May 26, 2009 at 05:28:35
Specs: Microsoft Windows XP Professional, 2.327 GHz / 2013 MB

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!?!

See More: dsquery/dsget For loop help!

Report •

May 26, 2009 at 06:33:47
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.


Report •

May 26, 2009 at 08:31:09
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?

Report •

Related Solutions

Ask Question