Bei Migrationen von Postfächern von einem Exchange Server auf einen anderen müssen oft die Outlook Profile neu angelegt werden. Dabei kann es sinnvoll sein, zunächst alle vorhandenen Outlook Profile zu löschen, nebst den Daten, die damit verbunden sind (*.OST Dateien, Offline Adressbuch, *.NST Dateien)
Diese Aufgabe lässt sich per Powershell erledigen. Das folgende Script funktioniert für Outlook Versionen ab Outlook 2007 bis einschließlich Outlook 2016. Mit Einführung von Outlook 2013 wurde der Pfad in der Registry geändert, unter dem die Profilinformationen gespeichert werden.
<# .SYNOPSIS Removing all Outlook Profiles. .DESCRIPTION The script is intended to remove all Outlook Profiles via Registry .EXAMPLE .\remove-olprofiles.ps1 .NOTES Version: 1.0 File Name: remove-olprofiles.ps1 Author: Roland Ehle Requires: Powershell >= 2.0, Microsoft Outlook 02/2017 - Initial Version #> $ostlocation = $env:LOCALAPPDATA + "\Microsoft\Outlook\" $oablocation = $ostlocation + "\Offline Address Books\" $oldoutlookprof = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\" $o2k13prof = "Software\Microsoft\Office\15.0\Outlook\Profiles\" $o2k16prof = "Software\Microsoft\Office\16.0\Outlook\Profiles\" $olprofs = @() # We have to make sure, that Outlook is not running get-process "Outlook" -ea SilentlyContinue | kill get-process "lync" -ErrorAction SilentlyContinue | kill get-process "UcMapi" -ErrorAction SilentlyContinue | kill sl HKCU: $olprofs += get-childitem $oldoutlook -ea SilentlyContinue if (test-path $o2k13prof) { $olprofs += Get-ChildItem $o2k13prof -ea SilentlyContinue } if (test-path $o2k16prof) { $olprofs += Get-ChildItem $o2k16prof -ea SilentlyContinue } if ($olprofs.Count -gt 0) { foreach ($olprof in $oldoutlookprofs) { Remove-Item $olprof -Recurse -Force } } sl c: sl $ostlocation # Delete OST Files $ostfiles = @() $ostfiles += get-childitem $ostlocation -Name *.ost foreach ($ostfile in $ostfiles) { Remove-Item $ostfile -Force } # Delete NST Files $nstfiles = @() $nstfiles += Get-ChildItem $ostlocation -Name *.nst foreach ($nstfile in $nstfiles) { Remove-Item $nstfile -Force } # Delete Offline Address Books sl $oablocation $oabs = @() $oabs += Get-ChildItem $oablocation foreach ($oab in $oabs) { remove-item $oab -Recurse -Force }
Pingback: Neues Outlook Profil per Powershell anlegen – Rolands Erinnermich