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 
相關問題