Reports the name of the Exchange organization from a Microsoft Exchange Server.

Visual Basic
Edit|Remove
On Error Resume Next 
Set ObjRoot = GetObject("LDAP://RootDSE") 
strConfigNC = ObjRoot.Get("configurationNamingContext") 
Set colExchangeContainer = GetObject _ 
 ("LDAP://CN=Microsoft Exchange,CN=Services," & strConfigNC)
If Err = 0 Then 
  For Each objExchangeOrg In colExchangeContainer
    If (objExchangeOrg.Class = "msExchOrganizationContainer") Then 
      Wscript.Echo "Exchange Organization name: " & _
       objExchangeOrg.Get("CN") 
    End If 
  Next
Else
  WScript.Echo "Exchange not installed."
End If