Manchmal muss das aktuelle Outlook-Profil ersetzt werden, weil es z.B. korrupt ist.

Folgendes Script erledigt dies in Sekunden und beendet auch ein evtl. laufendes Outlook.
Das alte Profil wird dabei nicht gelöscht. Dadurch kann man ggf. auf die Einstellungen zurückgreifen.

 

$Path1 = "Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
$Path2 = "Registry::HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles"
$DefaultPath = "Registry::HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook"

If ( -not ( Test-Path -Path $Path1 ) )
	{
	$Path1 = $null
	}
If ( -not ( Test-Path -Path $Path2 ) )
	{
	$Path2 = $null
	}

if ( -not $Path1 -and -not $Path2 )
	{
	write-Error "Reg-Path does not exist"
	exit
	}

$Val = (Get-ItemProperty -Path $DefaultPath -Name DefaultProfile).DefaultProfile

#Check if Outlook is runing end end the proccess
$Outlook = Get-Process -Name "OUTLOOK"
if ( $Outlook )
	{
	$OLPath= $Outlook.Path
	$Outlook | Stop-Process -Force
	}

if ( $Val -like "Outlook*" )
	{
	#Profile "Outlook" already exist. Use Timestamp to be unique
	$Profile = "Outlook-" + $(Get-Date -UFormat "%y%m%d%H%M")
	}
else
	{
	$Profile = "Outlook"
	}

# Create empty Profile on new Position
if ( $Path1 )
	{
	New-Item -Path $( Join-Path -Path $Path1 -ChildPath $Profile ) -Force | Out-Null
	}

# Create empty Profile on new legacy Position
if ( $Path2 )
	{
	New-Item -Path $( Join-Path -Path $Path2 -ChildPath $Profile ) -Force | Out-Null
	}

# Set new Profile as default
New-ItemProperty -Path $DefaultPath -Name DefaultProfile -Value $Profile -PropertyType String -Force | Out-Null	

# Start Outlook if it was running...
if ( $OLPath )
	{
	Start-Process -FilePath $OLPath -WindowStyle Minimized
	}

 

Neues Outlook-Profil erstellen

Das könnte dir auch gefallen

Schreibe einen Kommentar