{"id":190,"date":"2021-02-07T19:37:39","date_gmt":"2021-02-08T00:37:39","guid":{"rendered":"http:\/\/www.geekythings.me\/?p=190"},"modified":"2021-02-07T19:37:39","modified_gmt":"2021-02-08T00:37:39","slug":"migrating-your-auto-complete-history-to-a-new-outlook-201x-profile-with-powershell","status":"publish","type":"post","link":"https:\/\/www.geekythings.me\/?p=190","title":{"rendered":"Migrating your auto-complete history to a new Outlook 201X profile with Powershell"},"content":{"rendered":"\n<p>In the past with nk2 files, the migration from of Outlook Autocomplete addresses was a lot easier as you just copied the .nk2 file from <em>%AppData%\\Roaming\\Microsoft\\Outlook<\/em> to the new profile.<\/p>\n\n\n\n<p>As I found out, the steps to migrate the new cache files for Outlook 2010 and greater <strong>(Stream_Autocomplete<\/strong>*.*) require some extra steps as I found here:<br><a href=\"https:\/\/blog.zensoftware.co.uk\/2014\/05\/29\/how-to-copy-the-auto-complete-information-to-a-new-outlook-profile\/\">https:\/\/blog.zensoftware.co.uk\/2014\/05\/29\/how-to-copy-the-auto-complete-information-to-a-new-outlook-profile\/<\/a> <\/p>\n\n\n\n<p>To speed this up,  I have made a powershell script to make this a bit easier. Please note that you will need to do the following first:<br>&#8211; send one message in the new Outlook profile.<br>&#8211; make sure that Outlook is closed.<\/p>\n\n\n\n<p>The code is below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cls\n#Function from https:\/\/devblogs.microsoft.com\/scripting\/hey-scripting-guy-can-i-open-a-file-dialog-box-with-windows-powershell\/\n\nFunction Get-FileName($initialDirectory)\n{  \n &#91;System.Reflection.Assembly]::LoadWithPartialName(\"System.windows.forms\") |\n Out-Null\n $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog\n $OpenFileDialog.initialDirectory = $initialDirectory\n $OpenFileDialog.filter = \"All files (*.*)| *.*\"\n $OpenFileDialog.ShowDialog() | Out-Null\n $OpenFileDialog.filename\n} #end function Get-FileName\n\n\n$Flag =0\n$autocompletecachedir = \"$($env:userprofile)\\appdata\\local\\microsoft\\outlook\\roamcache\"\nif (get-process outlook -ErrorAction SilentlyContinue) {\n\"Outlook is currently open. Please close it to proceed.\"\n$Flag = 1\n}\nIf ($flag -eq 0){\n$currentacc = get-childitem -path $autocompletecachedir -Filter stream_Autocomplete_*.dat|sort LastWriteTime -desc|select -first 1\nIf ($currentacc){$flag++}\nIf ($flag -gt 0) {\n\"Found the current Autocomplete Cache file:\"\n$currentaccpath = \"$autocompletecachedir\\$($currentacc.name)\"\n\n\"Please find the old Autocomple files to restore.\"\n$Oldaccpath = Get-FileName -initialDirectory \"c:\\\"\n\nif (test-path $oldaccpath){$flag++}\nIf ($flag -gt 1 ){\n\t\"Found the old Autocomplete file to restore:\"\n\t$Oldacc = get-item \"$oldaccpath\"\n\t$Oldacc\n\t\"\"\n    \"Backing up current Autocomplete cache...\" \n\t&amp;robocopy \"$autocompletecachedir\" \"$autocompletecachedir\\backup\" $($currentacc.name) \/njh \/njs\n\tremove-item \"$autocompletecachedir\\$($currentacc.name)\" -force\n\t\"Restoring old Autocomplete cache...\"\n\t&amp;robocopy \"$($Oldacc.directoryname)\" \"$autocompletecachedir\" $($Oldacc.name) \/njh \/njs\n\t\"Renaming $autocompletecachedir\\$($Oldacc.name) to $($currentacc.name)\"\n\trename-item -path  \"$autocompletecachedir\\$($Oldacc.name)\" -NewName \"$($currentacc.name)\"\n}\nElse{\"No Autocomplete file found.\"}\n\n}\nelse {\n\"No Autocomplete cache found. Aborting...\"\n}\n\"Done! Please check Outlook and confirm the results.\"\n}<\/code><\/pre>\n\n\n\n<p>Hopefully this will be end of your google search for now! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past with nk2 files, the migration from of Outlook Autocomplete addresses was a lot easier as you just copied the .nk2 file from %AppData%\\Roaming\\Microsoft\\Outlook to the new profile. As I found out, the steps to migrate the new &hellip; <a href=\"https:\/\/www.geekythings.me\/?p=190\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-190","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.geekythings.me\/index.php?rest_route=\/wp\/v2\/posts\/190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.geekythings.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.geekythings.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.geekythings.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.geekythings.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=190"}],"version-history":[{"count":2,"href":"https:\/\/www.geekythings.me\/index.php?rest_route=\/wp\/v2\/posts\/190\/revisions"}],"predecessor-version":[{"id":192,"href":"https:\/\/www.geekythings.me\/index.php?rest_route=\/wp\/v2\/posts\/190\/revisions\/192"}],"wp:attachment":[{"href":"https:\/\/www.geekythings.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.geekythings.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.geekythings.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}