Script to update PST File locationsBookmark:Question:
We are running a project to migrate the backend file location for 1000 user created PST files to a new 2008 File server. The server will not re-use the previous server name and we will not be able to use a DNS alias for the old server to point to the new one.
Users have historically used personal folders stored in their networked homedrives (Yes, we know it is not a Microsoft best practise methodology for PST file usage) and we are planning to move all pst files to a decidated PST file server and then update the path location to the pst files with no user impact or intervention.
I am looking at implementing a logon script to remap the pst file to the new location. The workflow will be as follows
Nighttime (After backups complete) robocopy pst files from \\oldserver\homedrive$ to \\newserver\pstdir$
Remove permissions to the source PST file
On user logon - map new network drive (P:\ to the \\newserver\pstdir$ directory (this will be a security locked down folder based on the user's name)
Logon script to query the registry or mapi profile of the user and for every pst file connected (Some users have more than 1) change the path from M:\ (current user homedrive mapping) to P:\ (preserving the rest of the path, for example if a user had M:\MyMail\October-Archive.pst file then the remap should be P:\MyMail\October-Archive.pst)
I am ok for the 1st parts of the problem, but I am stuck on the Logon script, as the value stored in the registry is a hexidecimal string. So I need to query all outlook profiles for the user, compile an array of pst file string locations, decode the strings, rewrite the new path, encode the string and write it back.
I have found a few scripts on the net that in part achieve some aspects of this, but nothing that provides a complete solution.
Mapi profile information is stored in the registry here "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
The key name for a PST file is either "01020fff" "001f6700" (Example below)
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Default Outlook Profile\93abdcf58c80884b92c1b8c1b272dc12
01023414 REG_BINARY 4E495441F9BFB80100AA0037D96E0000
001f300a REG_BINARY 6D0073007000730074002E0064006C006C000000
001f3d13 REG_BINARY 7B00360034003800350044003200360032002D0043003200410043002D0031003100440031002D0041004400330045002D003100300041003000430039003100310043003900430030007D000000
00033e03 REG_BINARY 21000000
00033009 REG_BINARY 00000000
001f3001 REG_BINARY 50006500720073006F006E0061006C00200046006F006C0064006500720073000000
001f3006 REG_BINARY 50006500720073006F006E0061006C00200046006F006C0064006500720073000000
01023d0c REG_BINARY 2BDB2EC4365E81428904AB3D06E7FD3E
001f3d09 REG_BINARY 4D005300550050005300540020004D0053000000
00036770 REG_BINARY 00000080
00036702 REG_BINARY 00000010
01020fff REG_BINARY 0000000038A1BB1005E5101AA1BB08002B2A56C200006D737073742E646C6C00000000004E495441F9BFB80100AA0037D96E0000000043003A005C00540065006D0070005C00540065007300740031002E007000730074000000
001f6700 REG_BINARY 43003A005C00540065006D0070005C00540065007300740031002E007000730074000000
001f3004 REG_BINARY 0000
01020ff9 REG_BINARY 636E08EC45E2F449AB50A4F2AB97DDF3