Solved

Using dsmod user with for /f - Inserting multiple users

Posted on 2011-03-17
5
1,322 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
[X]
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
  • 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Are you unable to synchronize your OST (Offline Storage Table) file with Microsoft Exchange Server? Is your OST file exceeding 2 GB size limit? In Microsoft Outlook 2002 and earlier versions, there is a 2 GB size limit for the OST file. If the file …
If your system is showing symptoms of browser hijacks or 'google search redirects' check out my other article (http://rdsrc.us/u3GP7A) first and run the tool TDSSKiller (http://rdsrc.us/GDBBs4) to get rid of the infection. Once done, and if the …
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…

738 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