切换到宽版
  • 6892阅读
  • 0回复

[求助]使用脚本添加一个共用文件夹副本服务器 [复制链接]

上一主题 下一主题
 
只看楼主 倒序阅读 0楼  发表于: 2011-03-13
— 本帖被 YOYO 从 Exchange 脚本中心 移动到本区(2015-06-25) —
  • 脚本环境:Visual Basic
  • 适合版本:Exchange 2003
  • 适用平台:
  • 脚本作用:添加一个共用文件夹副本服务器
使用此脚本可以添加一个共用文件夹副本服务器

Const strWMINameSpace = "root/MicrosoftExchangeV2"
Const strWMIInstance = "Exchange_PublicFolder"
' The DN for the public folder store of the new server, best found via WMI or ADSIEDIT
' Configuration, Services, Microsoft Exchange, Domain, Administrative Groups, Organization,
' Servers, Server, Information Store, DN
Const NEWREPLICASERVER = "cn=Public Store,cn=Storage Group,cn=InformationStore,cn=mail,cn=Servers,cn=contoso," & _
        "cn=Administrative Groups,cn=contoso,cn=Microsoft Exchange,cn=Services,cn=Configuration,dc=contoso,dc=com"
strComputer = "oldmailserver"
Dim strWinMgmts  
' Connection string for WMI
Dim objWMIExchange
' Exchange Namespace WMI object
Dim colPublicFolders
' ExchangeLogons collection
Dim objWMIPublicFolder  
' A single ExchangeLogon WMI object
' Create the object string, indicating WMI (winmgmts), using the
' current user credentials (impersonationLevel=impersonate),
' on the computer specified in the constant strComputer, and
' using the CIM namespace for the ExchangeClusterResource provider.
strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//" & strComputer & "/" & strWMINameSpace
Set objWMIExchange =  GetObject(strWinMgmts)
' The Resources that currently exist appear as a list of ExchangeLogon instances in the Exchange namespace.
Set colPublicFolders = objWMIExchange.InstancesOf(strWMIInstance)
' Were any Exchange_PublicFolder Instances returned?
Wscript.Echo "Number of Public Folders returned: " & colPublicFolders.Count
If (colPublicFolders.count > 0) Then
'  If yes, iterate through the list of Exchange_PublicFolder objects.
For Each objWMIPublicFolder in colPublicFolders
'   Return the address book name of the public folder instance
  Wscript.Echo"Address Book Name: " & objWMIPublicFolder.AddressBookName
'   Check to see if the public folder instance has a replica on the new server
'   If it doesn't have a replica on the new server, create a replica on the new server
  If CheckReplica(objWMIPublicFolder) = TRUE Then
   Wscript.Echo VBTAB & "Replica on NEWREPLICASERVER"
  Else
   objWMIPublicFolder.AddReplica NEWREPLICASERVER
   Wscript.Echo VBTAB & "Replica added pointing to NEWREPLICASERVER"
  End If
Next
Else
'  If no Exchange_PublicFolder instances were returned, display that.
WScript.Echo "WARNING: No Exchange_PublicFolder instances were returned."
End If
Function CheckReplica(objWMIPublicFolder)
'  Create a "switch" to flip if the new server DN is in the replica list  
bolNEWREPLICASERVERCheck = FALSE
'  Loop through the replica list and compare to the DN of the new server
'  If there is a match found, flip the "switch"
For Each strReplica in objWMIPublicFolder.ReplicaList
  If strReplica = NEWREPLICASERVER Then
   bolNEWREPLICASERVERCheck = True
  End IF
Next
'  Return the results of the check as TRUE or FALSE  
CheckReplica = bolNEWREPLICASERVERCheck
End Function

分享到
快速回复
限60 字节
 
上一个 下一个