Solved

Using dsmod user with for /f - Inserting multiple users

Posted on 2011-03-17
5
1,312 Views
Last Modified: 2012-05-11
Hey guys,

I seem to be having a lot of trouble with something I thought would be relatively easy. I am trying to use a list of users. I am having two issues:

1. I can run the command on the user from the CLI, however, as soon as I integrate the for /f it doesn't recognise the input.
2. I am yet to get this working with a user with a FQDN with a space in their CN

This is the code I have so far:

 
set Users=c:\temp\users.txt
(
pushd C:\Temp
for /f %%a in ("%Users%") do (
   dsmod user "CN=%%a,CN=Users,DC=roads,DC=vic,DC=gov,DC=au" -office testoffice
)
echo "%Users%"
popd
) >>dsmod.log 2>&1

Open in new window


This is the error output I am getting:

 
C:\temp>(dsmod user "CN=c:\temp\users.txt,CN=Users,DC=roads,DC=vic,DC=gov,DC=au" -office testoffice ) 
dsmod failed:Value for `Target object for this command' has incorrect format.
type dsmod /? for help."c:\temp\users.txt"

Open in new window


Hope someone can help.
Cheers
G_M
0
Comment
Question by:G_M
  • 2
  • 2
5 Comments
 
LVL 26

Expert Comment

by:farhankazi
ID: 35162896
Change following line

for /f %%a in ("%Users%") do (

with

for /f "delims=*" %%a in (%Users%) do (

Hope this helps!
Farhan
0
 

Author Comment

by:G_M
ID: 35163158
hmmm... the error goes away, however, the command still doesn't execute properly.

It still substitutes "C:\Temp\users.txt"  for the %%a instead of the values in the users.txt


... stumped
0
 
LVL 26

Accepted Solution

by:
farhankazi earned 500 total points
ID: 35163875
What about this:
for /f "delims=*" %%a IN ('TYPE %Users%') do (
0
 
LVL 51

Expert Comment

by:Netman66
ID: 35166055
Yes, don't use a variable AND run the script from the same folder as the text file.

for /f "delims=*" %%a in (users.txt) do (

0
 

Author Comment

by:G_M
ID: 35170225
Fantastic, all works. This is the complete solution I'm working with.

Thank you for your help.
G_M

 
set Users=c:\temp\users.txt
set Office=Sunshine
pushd C:\Temp
(
for /f "delims=*" %%a IN ('TYPE %Users%') do (
   dsmod user "CN=%%a,OU=User Accounts,DC=cec,DC=cec,DC=cec,DC=au" -office "%Office%"
)) >>dsmod.log 2>&1
popd

Open in new window

0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup". After a while, you have entered a loop for Auto repair which does not fix anything and you will be in a  panic as all your work w…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now