Exchange 2007 / 2010 – Export all Registry Settings using Powershell…

by Andy Grogan on September 2, 2009 · 0 comments

in Exchange 2007 (General), Exchange Registry Settings, Exchange Services, Powershell

Been doing a little tidy up and performance review recently on a number of my Exchange Servers in work, and whilst doing so I noticed that I have (over the years) made a number few changes to the Windows Registry in relation to the Exchange Services.
Whilst reviewing these changes, I can recall that there were a number of reasons as to why I had made them – for example performance, and transport issues which I had come across with suppliers.

However the fact that I had found these changes again and given that the reasons for making them is not the focus of this article, you could be forgiven for asking “why have I raised it?

Well two things occurred to me whilst I was reviewing these settings:

  1. If I had to restore from backup and not using the “System State” I would lost all of them and find it very hard to figure out which changes to make again in a restoration situation
  2. Going through the Exchange Services in the registry is hard going using Regedit

So given the above I started thinking about a way to export all Exchange the Exchange centric registry settings on a server into one file – which can be used for restoration or reference purposes later on.
I went through a number of methods, for example creating a little application in C# using the Registry class, and VBSCRIPT – however in the end I settled on a mix of Powershell and the Registry Command line application (Regedit.exe).

The following is the script which I came up with:

$Exch = Get-ChildItem -Path  HKLM:\system\CurrentControlSet\Services | where {$_.Name -like '*Exchange*'}
$RegSeed = $Exch.Count 
$SeedIndex  = 0 
$DirectoryPath = "c:\ExchRegDirectory"
if (!(Test-Path -path $DirectoryPath))  
 New-Item $DirectoryPath -type directory
 Remove-Item  $DirectoryPath -Recurse 
 New-Item $DirectoryPath -type directory 
While ($SeedIndex -ne $RegSeed){  
 $exe = "Regedit.exe" 
 $Fname =  "$DirectoryPath\ExchangeReg[$SeedIndex].txt" 
 & $Exe /e $Fname  $Exch[$SeedIndex].Name 
 $SeedIndex ++ 
$MergeApp = "cmd"  
$MergerFile = "ExchangeServices.dat" 
$ExchName = "ExchangeServices.txt"
& $MergeApp /c "Copy  $DirectoryPath\*.txt $DirectoryPath\$MergerFile" 
& $MergeApp /c "Del  $DirectoryPath\*.txt" 
& $MergeApp /c "Ren $DirectoryPath\$MergerFile  $ExchName"
Write-Host "Script Has  Completed"

You can download the above script from the following link:


In order the use the above script – download it to one of your Exchange Servers (it will work with any Exchange 2007 and 2010 server with either all roles installed or segregated roles (come to think of it, for if you install Powershell on your Exchange 2003 servers it should also work) and execute it from a Powershell Command Window (you do not have to use the Exchange Management Shell in order for it to work as it does not use any Exchange Specific CMDLETS).

For example if you download the script to the c:\ drive you could run it via the following method:


Then type “Powershell

From the Powershell command window type in the following commands:

Set-ExecutionPolicy  “RemoteSigned”
cd \

The following is an EXAMPLE screen output from the script:

Directory:  Microsoft.PowerShell.Core\FileSystem::C:\
Mode                LastWriteTime      Length Name 
----                -------------     ------ ----  
d----        13/09/2009     23:17            ExchRegDirectory  

 1 file(s) copied.  
Script Has Completed
Upon the script completing, you will find that on your Exchange server there  is a new Directory located in c:\ExchRegDirectory;  therein you will find a file called  “ExchangeServices.txt” – if you open that file in  Notepad you should see content similar to the following:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\system\currentcontrolset\services\MSExchange  ActiveSync] 
@="Automatically managed by Exchange"
[HKEY_LOCAL_MACHINE\system\currentcontrolset\services\MSExchange  ActiveSync\Diagnostics] 
"1 Requests"=dword:00000000 
"2  Configuration"=dword:00000000
[HKEY_LOCAL_MACHINE\system\currentcontrolset\services\MSExchange  ActiveSync\HTTP Header Controls]
[HKEY_LOCAL_MACHINE\system\currentcontrolset\services\MSExchange  ActiveSync\HTTP Header Controls\12.0] 
[HKEY_LOCAL_MACHINE\system\currentcontrolset\services\MSExchange  ActiveSync\HTTP Header Controls\12.1] 
[HKEY_LOCAL_MACHINE\system\currentcontrolset\services\MSExchange  ActiveSync\HTTP Header Controls\2.0] 

The size and content of this file will depend on the roles installed on the Exchange Server that you have executed the script against, the end result is a file which contains all of the registry settings which are relevant to Exchange on the server you have chosen to query.
Hope that this helps someone along the way.


{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: