Zoho Banner September 2011

Archive for May, 2010

The other day I had to uninstall Exchange 2010 from a server with the CAS and Hub Transport roles.  It all went well until the point where it was uninstalling the Hub Transport role.  The uninstall then ground to a halt with the following error:

Log Name:      Application
Source:        MSExchange Configuration Cmdlet – Management Console
Date:          20/05/2010 4:11:01 p.m.
Event ID:      4
Task Category: General
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      HUBCAS1.contoso.com
Description:
(PID 6920, Thread 31) Task Uninstall-MsiPackage writing error when processing record of index 0. Error: Microsoft.Exchange.Configuration.Tasks.TaskException: Couldn’t open package ‘D:\Program Files\Microsoft\Exchange Server\V14\Mailbox\MSFTE.MSI’. Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel. Error code is 1638. —> System.ComponentModel.Win32Exception: Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs on the Control Panel
   — End of inner exception stack trace —
   at Microsoft.Exchange.Management.Deployment.MsiUtility.GetProductCode(String packagePath)
   at Microsoft.Exchange.Management.Deployment.MsiUtility.IsInstalled(String packagePath)
   at Microsoft.Exchange.Management.Deployment.UninstallMsi.InternalValidate()

After scratching my head for a few minutes, I uninstalled Update Rollup 3 for Exchange Server 2010 and then re-tried the uninstall for Exchange.  It went through perfectly. 

I hadn’t realised it was necessary to remove any Update Rollups before uninstalling Exchange, but it it seems it is required in this case.

This is an updated version of the script that I wrote for Exchange Server 2007.  The new version works for both E2007, E2010 as well as environments where both versions coexist.

Ok, so the script is a bit messy and could use some polish – but, hey, it works for me :-)

########################################################## 
# Name: GetExchangeBuild.ps1 
# Author: Tony Murray 
# Version: 2.0 
# Date: 22/04/2010 
# Comment: PowerShell script to list build info 
# for each Exchange Server in the organisation 
# 
#########################################################    

Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -ErrorAction SilentlyContinue 
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue     

$exsrvs = (get-exchangeserver)     

foreach ($exsrv in $exsrvs) 
{ 
$version = (get-exchangeserver -identity $exsrv).admindisplayversion 
$edition = (get-exchangeserver -identity $exsrv).edition 
write-host “=====================================================” 
write-host “Exchange Server: $exsrv” 
write-host $version 
write-host “Edition: $edition” 
write-host “Installed Update Rollups:” 
$baseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(’LocalMachine’, $exsrv) 
$Version8 = "Version 8." 
If ($version -match $Version8) 
{ 
$regKey = “SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\ 
S-1-5-18\Products\461C2B4266EDEF444B864AD6D9E5B613\Patches\” 
} 
Else # Version is 14 
{ 
$regKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\ 
S-1-5-18\Products\AE1D439464EB1B8488741FFA028E291C\Patches\" 
} 
$baseKey = $baseKey.OpenSubKey($regKey) 
$Updates = $baseKey.GetSubKeyNames() 
ForEach($Update in $Updates) 
{ 
$fullPath= $regKey + $Update 
$UpdateKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey(’LocalMachine’, $exsrv) 
$UpdateKey = $UpdateKey.OpenSubKey($fullPath) 
$values = $UpdateKey.GetValueNames() 
ForEach($value in $values) 
{ 
if ($value -eq “DisplayName”) 
{Write-host $UpdateKey.GetValue($value)} 
} 
} 
write-host “=====================================================” 
}

Watch out for two the lines beginning with $regKey.  They might wrap in the window here but should be on one line.  Note also that WordPress does something funky with the character codes and you may need to replace the double-quote characters if you copy/paste the code. You can download the file here: getexchangebuildv2ps1.txt