Saturday, April 25, 2009

Run the Outlook Profile Migration Utility in a Login Script

Run the Microsoft Outlook Profile Migration utility from a KiXtart script at login (yes, part of a login script). Just drop the exprofre.exe file into the NETLOGON share on your domain controller and drop this crap (oops, script code) into your KiX login script, suck down a coffee and scream "Yeah baby!!!!"


Function MigrateOutlookProfile()
Dim $dc, $clientlog, $migprof, $exprof, $temp
$dc = SubStr(@LSERVER,3)
$exprof = @LSERVER+"\Netlogon\exprofre.exe"
$temp = ExpandEnvironmentVars("%temp%")
$clientlog = $temp+"\exprof_"+@wksta+".log"
If Exist($exprof) = 0
? "mgrOutlookProfile...: error - unable to locate exprofre.exe!"
Return
EndIf
If Exist($clientlog)
? "mgrOutlookProfile...: deleting previous log file..."
Del $clientlog /c
If @ERROR > 0
? "mgrOutlookProfile...: failed to delete log file!"
EndIf
EndIf
? "mgrOutlookProfile...: migrating outlook profile..."
$migprof = $exprof+" /targetgc="+$dc+" /v /n /logfile="+$clientlog
? "mgrOutlookProfile...: $migprof"
Run $migprof
? "mgrOutlookProfile...: process has been initiated and will continue"
? "mgrOutlookProfile...: check for the following log when finished..."
? "mgrOutlookProfile...: $clientlog"
EndFunction

No comments: