Skip to content

Delete Outlook profile

Here is a simple script to delete Outlook profile(s) and their OST’s, without having to go through all the nag of clicking too much.

This has only been tested on Windows 10 in combination with Outlook 2013 and Outlook 2016.

$User = $env:USERNAME
$Path = "C:\Users\" + $User + "\AppData\Local\Microsoft\Outlook"
$Key16 = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Outlook\Profiles"
$Key15 = "HKCU:\SOFTWARE\Microsoft\Office\15.0\Outlook\Profiles"

Stop-Process -Name OUTLOOK -Force -EA SilentlyContinue
Write-Host "Outlook is closing..." -BackgroundColor Green -ForegroundColor Black
Stop-Process -Name EXCEL -Force -EA SilentlyContinue
Write-Host "Excel is closing..." -BackgroundColor Green -ForegroundColor Black
Stop-Process -Name WINWORD -Force -EA SilentlyContinue
Write-Host "Word is closing..." -BackgroundColor Green -ForegroundColor Black
Stop-Process -Name ONENOTE -Force -EA SilentlyContinue
Write-Host "One Note is closing..." -BackgroundColor Green -ForegroundColor Black
Stop-Process -Name LYNC -Force -EA SilentlyContinue
Write-Host "Skype for Business is closing..." -BackgroundColor Green -ForegroundColor Black

$TestPath = Test-Path -Path $Path\*.ost
$GciPath =  Get-ChildItem -Path $Path -Recurse -Include *.ost,*.nst

if ($TestPath -eq $TRUE){
Remove-Item $GciPath -EA SilentlyContinue
}
else{
Write-Host ".OST not found, continuing..." -BackgroundColor Green -ForegroundColor Black
}

$TestPath16 = Test-Path -Path $Key16 -IsValid
$TestPath15 = Test-Path -Path $Key15 -IsValid

if ($TestPath16 -eq $TRUE){
Remove-Item $Key16 -Recurse -EA SilentlyContinue
Write-Host "Outlook 2016 profiles are removed." -BackgroundColor Green -ForegroundColor Black
}
elseif ($TestPath15 -eq $TRUE){
Remove-Item $Key15 -Recurse -EA SilentlyContinue
Write-Host "Outlook 2013 profiles are removed." -BackgroundColor Green -ForegroundColor Black
}
else{
Write-Host "Outlook 2016 and Outlook 2013 not found.`nContact support or remove the profile manually." -BackgroundColor Red -ForegroundColor Black
}

Write-Host "Outlook will start automatically after this." -BackgroundColor Green -ForegroundColor Black
Write-Host `r
Write-Host "Press any key to continue..." -BackgroundColor Green -ForegroundColor Black

$host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

Start-Process Outlook
Published inOffice 365Outlook

One Comment

  1. Six5 Six5

    Thanks for this, its a great script. Im running into an issue, even though the profile is being deleted, and when outlook reopens it says retrieving mailbox and gets me back into my mailbox. Im trying to get it to ask me to enter my creds again, because I want to sign back in with a different Office Account.

Leave a Reply to Six5 Cancel reply

Your email address will not be published.