An administrator is looking for an easy way to remove PST files from his user's profiles after configuring a policy to prevent the creation of PST files.
We recently implemented an email retention policy of 6 months for company email. We are enforcing the policy on Exchange 2010. Getting rid of the PST’s has been a headache. We disabled the creation of new PST’s and disabled PST growth using group policy. We asked users to close their old archives in Outlook 2010, and deleted the associated PST when they did, but many Outlook users are dragging their feet. We could delete the PSTs when Outlook is closed, but that will cause Outlook to error the next time it’s launched (and then the phone rings). We’re looking for a way to automatically detach PSTs, that is invisible to the end-user. We suspect this will have to be done programmatically.
Correct, removing the PST files can be done programmatically, but it won't be difficult. You can use the following VBScript in a logon script to remove PST files from the default profile on the computer (if Outlook is closed). If the script runs when Outlook is open, it will remove the PST files from the profile currently in use.
To use, copy the code below and paste it into Notepad. Save the file with a vbs extension. Double-click on the file to run it, or use it with a logon script to run when the user's log on their computer.
On Error Resume Next Dim objOutlook 'As Outlook.Application Dim Stores 'As Outlook.Stores Dim objFolder 'As Outlook.Folder Dim i 'As Integer Set objOutlook = CreateObject("Outlook.Application") Set Stores = objOutlook.Session.Stores i = 1 Do Until i > Stores.Count If Stores(i).ExchangeStoreType = 3 Then Set objFolder = Stores(i).GetRootFolder objOutlook.Session.RemoveStore objFolder Else i = i + 1 End If Loop
Remove all PST files except SharePoint Lists
If you are using SharePoint Lists linked to Outlook, the SharePoint data is in a PST file and will be removed using the script above. Of course, if you don't allow the creation of PST files, you can't link to SharePoint libraries anyway...
If you want to remove all PST files from the profile, except for the SharePoint List data file, use an If statement:
If Stores(i).ExchangeStoreType = 3 Then If Stores(i).DisplayName <> "SharePoint Lists" then Set objFolder = Stores(i).GetRootFolder objOutlook.Session.RemoveStore objFolder End if Else