Im letzten Artikel habe ich beschrieben, wie man per Powershell einen Shortcut auf dem Desktop anlegt. Hier folgt nun der Code, um PST-Dateien per Powershell in das Outlook Profil einzubinden. Dabei wird auf eine Textdatei zugegriffen, in der die jeweiligen Pfade zu den PST-Dateien abgelegt sind. Das Script stellt außerdem noch die Signatur aus einer vorherigen Sicherung wieder her.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | < # .SYNOPSIS Attach PST-Files to Outlook Profile .DESCRIPTION The Script is intended to attach PST-Files, which were formerly attached to the current Outlook Profile .EXAMPLE .\attach-psts.ps1 .NOTES Version: 1.0 File Name: attach-psts.ps1 Author: Roland Ehle Requires: Powershell >= 2.0, Microsoft Outlook 02/2017 - Initial Version #> $user = $env:USERNAME $rootfolder = "c:\autodisc\" $targetdir = $rootfolder + $user $inputfile = $targetdir + "\pstfiles.txt" $signaturesrc = $targetdir + "\Signatures" $signaturedst = "$env:APPDATA\Microsoft\" if (test-path $inputfile) { Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null $outlook = new-object -comobject outlook.application $namespace = $outlook.GetNameSpace("MAPI") $pstfiles = @() $pstfiles = gc $inputfile foreach ($pstfile in $pstfiles) { if (Test-Path $pstfile) { $namespace.AddStore("$pstfile") } } } # Restore Signature(s) if (Test-Path $signaturesrc) { Copy-Item $signaturesrc -Recurse -Force -Destination $signaturedst } |