Showing results for 
Search instead for 
Did you mean: 
Level 6

Acording to best practice documentation, (I forget where now, I will update this if I find it again -- section 5 of the resolution) it is a good idea to periodically reduce the number of Outlook profiles there are on EV servers for the EV service account.

When I checked this on our servers some of them had 273 Outlook profiles. As far as I am aware high numbers of these profiles would suggest problems connecting to Exchange servers, so these profiles should be removed and the EV services restarted to refresh MAPI connections.

This got me thinkinng, how could we know when it was time to check for these profiles and delete them? We have 7 EV email archiving servers in our environment and this would quickly get boring, be rarely checked and forgotten.

Enter Powershell and its ability to interegate the registry.

An example in our environment of these profiles: HKEY_USERS\S-1-5-21-4027188898-615063133-987009230-144213\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\VaultMbxAgent-ExchangeServer1-10332-1316930779-0-576-0

I have created a script which is scheduled to run everyday on each of our EV servers. The script checks for the correct user hive under HKEY_USERS, drills down to where the EV service account Outlook profiles are found, and counts them. For the moment I have the script alerting via email if more than 50 Outlook profiles are found. I have not automated the deletion of the profiles, I generally keep well clear of deleting any data in my scripts.

To use this script you will need to rename it to .ps1, and schedule it with a .cmd file containing something along the lines of:

Powershell.exe -command "./EVServiceAccountOutlookProfiles.ps1"



Level 6
Partner    VIP    Accredited Certified


  When running, an error regarding 'execution of scripts is disabled on this system' might appear.

in Powershell, run "Set-ExecutionPolicy unrestricted", run the command again.

Additionally, when the script is manually run, it ends in: "PS HKU:\>"

If you change the last line "CD \" to "CD $ScriptPath" it will end in the folder where you started the PS1.

Obviously, when running the script using a command-file, you do not have this.  


Additional Request to Jeremy...

Is it possible to rework this, so you can have this script look at more EV-servers? Or do you need to run this on each server you want checked? Something like an inputfile with servernames, then do a for each loop or something?


Level 6

Hi Gertjan,

My initial intention was to be able to run the script from a management server and target the EV servers over the network, but I ran into either limitations in Powershell or limitations in my knowledge, so as the script stands it should be run on each EV server directly. Not ideal I know, but it works for now.



Partner    VIP   

Please note that I personally wouldn't recommend deleting the profiles.  I would prefer investigation in to why they aren't being cleaned up automatically (as they should)

Level 3

I like this script though, it is nice to able to be alerted to this kind of thing.

Thank you.



Version history
Last update:
‎09-28-2011 02:30 AM
Updated by: