Echo does not return variables

W

w1b0

Dear all,

I have a weird issue for you.

Below you find find a script that I made, that is intended for use
during an upcoming Sharepoint Migration.

This is what it does: in c:\temp\users-to-migrate.txt there is a list
of users that exist on our internal LAN domain controller, and on an
domain controller outisde of the firewall. The thing is, is that the
naming convention for LAN differs from the one outside of the
firewall. So in the c:\temp\users-to-migrate.txt file are the CN's of
those users needed to migrate. With LDIFDE I actively query the AD's
of both environments.

I put the entire thing i a FOR DO-loop, as you can see.

The whole thing works quite nice, I thought LDIFDE was the tuff nutt
to crack, until I stumbled upon this: echo does not return my
variables. It's these lines that cause me haedaches:
FOR /F "tokens=*" %%G IN (c:\temp\extra1.txt) DO SET E3=%%G
FOR /F "tokens=*" %%H IN (c:\temp\dslan1.txt) DO SET DS=%%H

The main thing of the script is to generate 2 variables, 1 for old
user and 1 for new user, so that in the end, I can use the following
Sharpeoint command to migrate them:

stsadm -o migrateusr -oldlogin=%E3% -newlogin=%DS% -ignoresidhistory.
I need to migrate 800+ users, so to do it manually is definately not
an option.

I really have no clue what I am doing wrong.

Can you help me out? Any info is appreciated.

Cheers,

w1b0
####################################################################################################################################################
echo off
PROMPT=$P$G

echo --- > c:\temp\ldifde-output.txt
echo --- > c:\temp\stsadm-output.txt
echo --- > c:\temp\Extranet03-Users.txt
echo --- > c:\temp\DSLan-Users.txt

echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==-- > c:\temp\complete-output.txt
FOR /F "tokens=* delims=" %%A IN (c:\temp\users-to-migrate.txt) DO (
cls

echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==--==--
ECHO == Export for: %%A
ECHO.
echo %%A >> c:\temp\ldifde-output.txt

echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==--==--
echo === Export vanuit EXTRANET03 Active Directory
ldifde -m -v -f c:\temp\EXTRAtemp.txt -s S3A-Sharepoint1 -b
it_ntadmin EXTRAnet03 Fl0ridakeys -d "CN=%
%A,OU=Internal,OU=Workplace,DC=bla,DC=bla,DC=com" -p subtree -r
"(&(objectCategory=person)(objectClass=*)(mail=*))" -l
"sAMAccountname" >> c:\temp\ldifde-output.txt

type c:\temp\EXTRAtemp.txt | FIND /I "sAMAccountName: " >> c:\temp
\complete-output.txt
type c:\temp\EXTRAtemp.txt | FIND /I "sAMAccountName: " >> c:\temp
\Extranet03-Users.txt
type c:\temp\EXTRAtemp.txt | FIND /I "sAMAccountName: " > c:\temp
\extra1.txt

echo === Export vanuit DSLAN Active Directory
ldifde -m -v -f c:\temp\DSLANtemp.txt -s KM-DC01 -b it_ntadmin
dutchspace.nl floridakeys -d "CN=%%A,OU=Normal
Users,OU=Users,DC=bla,DC=com" -p subtree -r "(&(objectCategory=person)
(objectClass=*)(mail=*))" -l "sAMAccountname" >> c:\temp\ldifde-
output.txt

type c:\temp\DSLANtemp.txt | FIND /I "sAMAccountName: " >> c:\temp
\complete-output.txt
type c:\temp\DSLANtemp.txt | FIND /I "sAMAccountName: " >> c:\temp
\DSLan-Users.txt
type c:\temp\DSLANtemp.txt | FIND /I "sAMAccountName: " > c:\temp
\dslan1.txt

echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==--==--
echo == Postprocessing output
echo.
C:\temp\GR c:\temp\extra1.txt "sAMAccountName: " ""
C:\temp\GR c:\temp\dslan1.txt "sAMAccountName: " ""

echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==--==--
echo == Call variables
echo.
echo stsadm voor %%A: oldlogin=%E3% newlogin=%DS%
FOR /F "tokens=*" %%G IN (c:\temp\extra1.txt) DO SET E3=%%G
FOR /F "tokens=*" %%H IN (c:\temp\dslan1.txt) DO SET DS=%%H
ECHO=%E3%
ECHO=%DS%

echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==--==--
echo == run STSADM voor %%A
echo.
echo stsadm -o migrateuser oldlogin:%E3% newlogin:%DS%
echo stsadm voor %%A: oldlogin=%E3% newlogin=%DS% >> c:\temp
\stsadm-output.txt
echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==--==-- >> c:\temp\complete-output.txt
echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==--==-- >> c:\temp\ldifde-output.txt
echo --==--==--==--==--==--==--==--==--==--==--==--==--==--==--==--
==--==--==--==--==--==--==--==-- >> c:\temp\stsadm-output.txt
pause
)

del /Q c:\temp\EXTRAtemp.txt
del /Q c:\temp\DSLANtemp.txt
del /Q c:\temp\extra1.txt
del /Q c:\temp\dslan1.txt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top