I have made this script to reset outlook profile and configure a new profile. this script is deleting the old profile and creating a new one and launches outlook... I want that after launch of outlook the profile should also be configured automatically.. can anyone suggest how to do it further in this script.

if($process=(get-process 'outlook' -ErrorAction SilentlyContinue))
    Write-Host "Outlook is running so close it.." -ForegroundColor Green
    Write-Host "Outlook is stopped " -ForegroundColor Green

$child=(Get-ChildItem -Path $reg).name
foreach($item in $child)
    Remove-item -Path registry::$item -Recurse #-ErrorAction Inquire -WhatIf

Write-Host "All profiles removed successfully" -ForegroundColor Green
Write-Host "Now create new profile for outlook" -ForegroundColor Green
New-Item -Name "outlook" -Path $reg -Force -Verbose
Write-Host "New profile created" -ForegroundColor Green
Write-Host "Launch outlook with newly created profile" -ForegroundColor Green
Start-Process 'outlook' -ErrorAction SilentlyContinue -ArgumentList '/profile "outlook" '
  • 1
    You can add the ``n` to the Write-Host lines if you're just doing it for those and don't need them in redirected output. As for your question you probably need to create new registry entries that are similar to the ones you just deleted. Otherwise you will have to supply additional information what you mean by "configured".
    – Seth
    Nov 2, 2016 at 14:21

3 Answers 3


The best way to create a mail profile from powershell is probably by importing a PRF file as described in this article: https://www.howto-outlook.com/howto/deployprf.htm#script

I'll make a short set by step guide

Download the OCT files

Place the Admin folder which u extract from that install into the directory with the installation of the Office Version and then run from the command line setup.exe /admin

After doing so You will get a office Setup and you can skip everything and go right away to Outlook Profile enter image description here Enter the settings you desire in here

After doing so head over to Export Settings and save the PRF file somewhere on the network.

Now there are 2 ways of doing this

  1. Launching Outlook.exe with a parameter Execute Outlook.exe /importprf "\\path\to\your\prf\file.prf" You should only run this command once though. So as a login script which keep being fired of it could be a bad idea.
  2. Setting a Registry Key to import the file
    • Key: HKEY_CURRENT_USER\Software\Microsoft\Office\<version>\Outlook\Setup
    • Value name: ImportPRF
    • Value type: REG_SZ
    • Value: path to prf-file

For this Registry value to work, the FirstRun and First-Run value may not exist in the Setup key.

This way it will only import the file once when outlook is first started.


Disclosure: I represent the product I'm mentioning below

This could be done rather easily with PowerMapi, a powershell module that let's you do advance stuff with mapi directly, including outlook profiles.

I don't know the depth of the issue driving the question, but realize that this option would also require access to the module DLL on the users' hosts. If that's a blocker, disregard.

The first thing to know is that a MAPI profile can only be mostly configured, not completely. Outlook completes the configuration on first launch. I'll assume the real request is to be able to do this change without requiring any prompting for an end user to deal with...if so, the example below will work well for that. Furthermore, the standard way a profile is setup is very similar as you see when you create one manually from the control panel. Essentially, given a servername and mailbox identifier, a mapi method exists to "configure" the profile. This causes some communication to occur between mapi and an exchange server to fill in all the other necessary details. Then when outlook runs the next time, it logs on to the mailbox straight away and fills in any other details that Outlook needs in the profile.

PowerMapi example:
remove-MapiProfile "OldProfileName"
$newProf = new-MapiProfile -AddExchangeMailbox -ExchangeServername ex01.contoso.com -MailboxIdentifier useralias

There are also options with the cmdlet to add an Office365 mailbox in the new profile or to setup for Outlook Anywhere connections. Look at the details for new-MapiProfile.

Be aware that the example above will still prompt for a username and password if the current user is not also the "owner" of the malibox. If the computer is not domain joined, or the user is logging in a a local user (not as a domain user), then there will be a prompt for credentials.

The new-MapiProfile cmdlet does accept credentials as a parameter, and if the creds provided have sufficient rights to access exchange, the cmdlet will complete without prompts. However, this would also mean embedding credentials into the cmdlet/script...which is generally a no-no. Lastly, the -Credentials feature is showing not work work with Windows10 and Outlook 2013 and later because MS is changing the standard cred prompt to use the WinRT version, away from the older win32 calls. Be sure to test as always.

And finally, PowerMapi provides complete access to all properties and attributes of profiles, profile services, and profile providers. With such it is possible to pre-fill all the properties for a profile instead of having mapi do the "configure" call that requires network communication. However, that should be left for those familar with mapi.


I am trying to do the same with Office 2016, but I have 2 problems:

1. According to a Microsoft TechNet thread, "Outlook 2016 Default Profile via Office Customization Tool",

"PRF files do not work and are no longer needed in Outlook 2016 because accounts should be configured automatically in the account wizard when you use AutoDiscover."

Indeed, I am not being able to do it. Using a OCT (see point 2), I do not have the option from the Kage screenshot. Does someone know which version it was?

2. Anyway, a comment to Kage's answer (just up), due to the download link for 2016 is not valid anymore, now Microsoft overwrote the 2016 OCT version pointed by that link, you download it, but it is the one for 2019: it will contain the files shown in the next screenshot:

2019 files contained in the OCT from 2016 link

Therefore, it will be necessary to do it from the install media (or some alternative you can figure out), as mentioned in https://deploymentmonkey365.wordpress.com/2016/02/08/customizing-office-2016-using-office-customization-tool/ Basically, in the install media, as an Office 2016 DVD image, for example.

Using the screenshots from the page:

Installation media:

installation media

admin folder:

admin folder

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .