Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Using dsmod user with for /f - Inserting multiple users

Posted on 2011-03-17
5
1,317 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Migration of Exchange mailbox can be done with the ExProfre.exe tool. But at times, when the ExProfre.exe tool migrates the Exchange Server user profile, it results in numerous synchronization problems. Synchronization error messages appear in the e…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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