/build/static/layout/Breadcrumb_cap_w.png

create a new outlook profile with a console command

Been working on a project for the past couple of weeks, for moving the OST file located in %USERPROFILE%/AppData/Microsoft/Outlook to an alternate location.
So far I have a working script that finds out who the users are in the computer we are doing to installation, then moves the ost file to the location of our choice and sets the FORCEOSTPATH registry key to point to that directory:

@echo off
setlocal enabledelayedexpansion

taskkill.exe /f /im winword.exe
taskkill.exe /f /im excel.exe
taskkill.exe /f /im msaccess.exe
taskkill.exe /f /im outlook.exe
taskkill.exe /f /im officelivesignin.exe
taskkill.exe /f /im infopath.exe
taskkill.exe /f /im onenote.exe
taskkill.exe /f /im onenotem.exe
taskkill.exe /f /im powerpnt.exe
taskkill.exe /f /im mspub.exe
taskkill.exe /f /im mspscan.exe
taskkill.exe /f /im mspview.exe
taskkill.exe /f /im ois.exe
taskkill.exe /f /im communicator.exe
taskkill.exe /f /im UcMapi.exe

:exec
dir /b c:\users > dir.txt

for /f %%g in (dir.txt) do (
set Exclude=False
find /i "%%g" exclude.txt
if ERRORLEVEL 0 if not ERRORLEVEL 1 set Exclude=True
echo !Exclude! to exclude %%g

if !Exclude!==False echo Processing new loop on %%g
if !Exclude!==False echo Processing new loop on %%g
if !Exclude!==False echo Running WMIC
if !Exclude!==False wmic useraccount where name="%%g" get sid /format:list > sid.txt
if !Exclude!==False for /f "skip=2 tokens=2 delims==" %%i in ('type sid.txt') do (
if !Exclude!==False echo Processing registry entries for %%i in loop %%g
if !Exclude!==False echo running reg add for %%i
if !Exclude!==False REG ADD "HKU\%%i\Software\Microsoft\Office\14.0\Outlook" /v "ForceOSTPath" /t REG_EXPAND_SZ /d "c:\users\%%g\Outlook" /f
echo.
)
if !Exclude!==False echo Creating c:\users\%%g\OUTLOOK
if !Exclude!==False echo Creating c:\users\%%g\OUTLOOK
if !Exclude!==False if not exist c:\users\%%g\OUTLOOK md "c:\users\%%g\OUTLOOK"
if !Exclude!==False echo Deleting old OSTs
if !Exclude!==False echo Deleting old OSTs with forfiles 
if !Exclude!==False FORFILES /p ìc:\users\%%g\AppData\Local\Microsoft\Outlook" /s /m *.ost /D +15 /C ìcmd /c del /Q c:\users\%%g\AppData\Local\Microsoft\Outlook\*.ost
REM FORFILES /p c:\users\%%g\appdata\Local\Microsoft\Outlook" /s /m *.ost /D -14 /C cmd /c move /Y c:\users\AppData\Local\Microsoft\Outlook\*.ost" c:\users\%%g\OUTLOOK
if !Exclude!==False echo Moving remaining OSTs
echo.
if !Exclude!==False echo Moving remaining OSTs 
if !Exclude!==False move /Y "c:\users\%%g\AppData\Local\Microsoft\Outlook\*.ost" "c:\users\%%g\OUTLOOK"
if !Exclude!==False echo Ending loop for %%g
if !Exclude!==False echo Ending loop for %%g 
)
And our MSOFFICE2010 Install:

@echo off

rem kill all applications that may cause install failure!

taskkill.exe /f /im winword.exe
taskkill.exe /f /im excel.exe
taskkill.exe /f /im msaccess.exe
taskkill.exe /f /im outlook.exe
taskkill.exe /f /im officelivesignin.exe
taskkill.exe /f /im infopath.exe
taskkill.exe /f /im onenote.exe
taskkill.exe /f /im onenotem.exe
taskkill.exe /f /im powerpnt.exe
taskkill.exe /f /im mspub.exe
taskkill.exe /f /im mspscan.exe
taskkill.exe /f /im mspview.exe
taskkill.exe /f /im ois.exe

rem install with unimsoconfig.xml
setup.exe /adminfile Updates/unimso2010.msp

exit /b %EXIT_CODE%

The main problem we have been running into, is that we recently discovered this wont work on an existing profile and will only work on a new profile.  Since that is the case, I have been trying to find out a way to create a new profile by command line so that we can create it as part of the migration process.  So far the only scripts I have come up with are powershell scripts for making and setting up a new Exchange Mailbox but nothing really tangible on creating an outlook profile from command line.

Is it just not possible or can someone point me in the right direction on how to do it with Batch Script or Powershell.  If its on Powershell can you provide some examples as I consider myself a total N00B when it comes to Powershell scripting.


0 Comments   [ + ] Show comments

Answers (1)

Posted by: SMal.tmcc 10 years ago
Red Belt
0
http://lmgtfy.com/?q=create+outlook+profile+command+line

Comments:
  • I did google "create outlook profile with command line" but none of the answers I found are viable for the deployment I am doing. Anyways If I come to ITninja to post its not because I am lazy and I havent done my homework of "googling" everything, its because I have exhausted my reseach and I have run out of ideas. - gpalau 10 years ago
    • I was looking at you may have to create a prf file and then import it. There are then command switches you run to reset, import or force switch to a new profile.

      Another tool you may be able to use to do this on the backdoor side is pstools psexec. - SMal.tmcc 10 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ