Solved Batch file looping

Dell / OPTIPLEX 755
December 1, 2011 at 04:09:12
Specs: Microsoft Windows 7 Enterprise, 2.333 GHz / 3965 MB
I have this... in run.bat

for /F %%A IN ("input.csv") DO dsget computer CN=%%A,OU=Staff,OU=Workstations,OU=Managed,OU=Staff,DC=my,DC=domain,DC=co,DC=uk -desc >> output.csv

input.csv basically has hostnames of machines so..

Hostname1
Hostname2
Hostname3

and so on, they are all in the same OU in AD so the DN i have is correct but for some reason I get the following error back from a command window.

C:\>run.bat

C:\>for /F %A IN ("input.csv") DO dsget compu
ter CN=%A,OU=Staff,OU=Workstations,OU=Managed,OU=Staff,DC=my,DC=domain,DC=co,DC=uk -desc

C:\>dsget computer CN=input.csv,OU=Staff,OU=W
orkstations,OU=Managed,OU=Staff,DC=my,DC=domain,DC=co,DC=uk -desc
dsget failed:Directory object not found.
type dsget /? for help.

Can anyone offer any help or advice?


See More: Batch file looping

Report •

#1
December 1, 2011 at 06:05:09
✔ Best Answer
FOR /F hates to have the file name to be in quotes. This is Command Script Got Ya # 34,753,391:
for /F %%A IN (input.csv) DO dsget computer CN=%%A,OU=Staff,OU=Workstations,OU=Managed,OU=Staff,DC=my,DC=domain,DC=co,DC=uk -desc >> output.csv

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question