3

有没有办法通过c#来检测哪个版本的Exchange Server正在运行(2007或2010)?使用C#确定系统上的Exchange服务器版本

+0

我希望我有交换测试,但我敢打赌,你可以通过扫描注册表来做到这一点。找出Exchange存储其版本信息的位置,然后查找它。 – 2010-11-16 18:37:24

+0

这个信息只能在服务器上使用吗? – 2010-11-16 19:36:01

回答

2

有VBScript中here是可以获得的版本使用WMI和AD域中的所有Exchange服务器。如果这是不可用的,你可以将这个逻辑转换成合适的.Net类。

'**************************************************************************** 
' This script created by Chrissy LeMaire ([email protected]) 
' Website: http://netnerds.net/ 
' 
' This script finds all Exchange Servers in AD. Includes Exchange Version. 
' 
' Run this script with admin privs on any computer within a domain. 
' 
' This script has only been tested on Windows Server 2003 
' 
' NO WARRANTIES, USE THIS AT YOUR OWN RISK, etc. 
'***************************************************************************** 

Set objAdRootDSE = GetObject("LDAP://RootDSE") 
Set objRS = CreateObject("adodb.recordset") 

varConfigNC = objAdRootDSE.Get("configurationNamingContext") 

    strConnstring = "Provider=ADsDSOObject" 
    strSQL = "SELECT * FROM 'LDAP://" & varConfigNC & "' WHERE objectCategory='msExchExchangeServer'" 
    objRS.Open strSQL, strConnstring 
    Do until objRS.eof 
Set objServer = GetObject(objRS.Fields.Item(0)) 
    Call getExchangeInfo(objServer.CN) 
Set objServer = Nothing 
     objRS.movenext 
    Loop 
    objRS.close 

Set objRS = Nothing 
Set objAdRootDSE = Nothing 

Sub getExchangeInfo(strServerName) 
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strServerName & "\\ROOT\MicrosoftExchangeV2") 
Set colItems = objWMIService.ExecQuery("Select * from Exchange_Server") 

For Each objItem in colItems 
MsgBox UCase(objItem.Name) & " (" & objItem.FQDN & ") is running Exchange " & objItem.ExchangeVersion 
Next 

Set colItems = Nothing 
Set objWMIService = Nothing 
End Sub 
相关问题