views:

36

answers:

0

Hi,

I am trying to update a replica list on a Exchange 2003 public folder. I am using the WMI namespace exchange_publicfolder to try and add an Exchange server (using the servers DN) to the AddReplica procedure. Every time I run this I get an invalid parameter as an exception.

Below is the code that I am using to do this.

      WMI.Connect(Server, credentials)

  Using WMISearcher As New ManagementObjectSearcher(WMI.Scope, & _ 
            New ObjectQuery(String.Format("SELECT * FROM Exchange_Publicfolder WHERE path='{0}'", Name)))
    Using PublicFolder As ManagementObjectCollection = WMISearcher.Get
      For Each Folder As ManagementObject In PublicFolder
        Dim BaseFolder As ManagementBaseObject = Folder.GetMethodParameters("AddReplica")
        BaseFolder("path") = ServerDN
        Folder.InvokeMethod("AddReplica", BaseFolder, Nothing)
      Next
    End Using
  End Using

I have used WMI before and I can see that the call is connecting to the correct public folder because i can itterate through the properies once the query has executed. I am not sure what I am doing wrong here.

If anyone has any ideas or comments the please let me know.

Thanks

Niall