Exchange 2013 Upgrade/Uninstall fails while uninstall Search Foundation for Exchange

This post is to explain one of the common problem experienced during upgrade / uninstall of 

Exchange Server 2013. The Process fails while uninstall Search foundation for Exchange. 

  

Exchange Server 2013 Setup logs show the error below.

"Error occurred while uninstalling Search Foundation for Exchange.System.Exception:

Cannot determine the product name registry subkey, neither the 'RegistryProductName'

application setting nor the 'CERES_REGISTRY_PRODUCT_NAME' environment variable was set."

catch
{
$deleteErrorMsg = "Failure
cleaning up SearchFoundation Data folder. - " + $dataFolderPath + " - " + $_.Exception.Message;
Write-ExchangeSetupLog -Error $deleteErrorMsg;
}
as run: "Error occurred while uninstalling Search Foundation for Exchange.System.Exception:

Cannot determine the product name registry subkey, neither the 'RegistryProductName' application

setting nor the 'CERES_REGISTRY_PRODUCT_NAME' environment variable was set
at
Microsoft.Ceres.Common.Utils.Registry.RegistryUtils.get_ProductKeyName()

in n:\src\search\foundation\Common\Utils\Registry\RegistryUtils.
at
Microsoft.Ceres.Exchange.PostSetup.DeploymentManager.DeleteDataDirectory()
at
Microsoft.Ceres.Exchange.PostSetup.DeploymentManager.Uninstall(String installDirectory, String logFile) at

CallSite.Target(Closure,CallSite,Type,Object,Object )"- System.Management.Automation.RuntimeException:

Error occurred while uninstalling Search Foundation for Exchange.System.Exception: Cannot determine

the product name registry subkey, neither the 'RegistryProductName' application setting nor

the 'CERES_REGISTRY_PRODUCT_NAME' environment variable was set
at
Microsoft.Ceres.Common.Utils.Registry.RegistryUtils.get_ProductKeyName() in n:\src\search\foundation\Common\Utils\Registry\RegistryUtils.
at
Microsoft.Ceres.Exchange.PostSetup.DeploymentManager.DeleteDataDirectory()
at
Microsoft.Ceres.Exchange.PostSetup.DeploymentManager.Uninstall(String installDirectory, String logFile)
at CallSite.Target(Closure , CallSite , Type , Object , Object )
at
System.Management.Automation.PowerShell.EndInvoke(IAsyncResult asyncResult)
at
Microsoft.Exchange.Configuration.MonadDataProvider.MonadPipelineProxy.

.ClosePipeline(MonadAsyncResult asyncResult)

 

Details:

--------- 

After installation of Exchange 2013 Installer process set the CERES_REGISTRY_PRODUCT_NAME 

variable under user variables. when it fails to set this variable Exchange server 2013 cannot connect

to search engine and other issues may be experienced .

Error will occur if Environment variable CERES_REGISTRY_PRODUCT_NAME is not properly

set prior to launch installer or Uninstaller. To list all the environment variables use :

 

Get-Childitem env: ( Or Dir Evn: )

To display values of the CERES_REGISTRY_PRODUCT_NAME environment variable, it is

missing because of which Exchange uninstall process is failed.

For Example :

 

 

To resolve the issue , run following command to set the values for CERES_REGISTRY_PRODUCT_NAME

$env:CERES_REGISTRY_PRODUCT_NAME = "Search Foundation for Exchange" .

 

Once this is done Upgrade /uninstall Exchange Server 2013 should complete.   

 

Manju