Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
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!?!

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

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?

![]() |
![]() |
![]() |

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