locked
Cannot Delete Contact Groups Through WMI RRS feed

  • Question

  • The code I'm attempting to use is below, however it throws an error at the delete command, telling me the contact group object doesn't contain the method DeleteInstance(), which looking at the MSDN entry for the object, is true.

    It tells me to delete it, I need to use Provider::DeleteInstance()

    What do I need to do to access this?

    Dim oFilesys, oFiletxt, sFilename, sPath
    Set oFilesys = CreateObject("Scripting.FileSystemObject")
    Set oFiletxt = oFilesys.CreateTextFile("c:\delgroups.txt", True)
    sPath = oFilesys.GetAbsolutePathName("c:\delgroups.txt")
    sFilename = oFilesys.GetFileName(sPath)


    strComputer = "myocsfrontendserver.domain.local"

    Set wmiServer = CreateObject("WbemScripting.SWbemLocator").ConnectServer()
    Query = "SELECT * FROM MSFT_SIPESUserSetting"
    Set LCUserEnum = wmiServer.ExecQuery(Query)

    For each LCUser in LCUserEnum  
     oFiletxt.WriteLine(LCUser.InstanceID & " " & LCUser.DisplayName)
     strUID = LCUser.InstanceID
      Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
     Set colItems = objWMIService.ExecQuery("SELECT * FROM MSFT_SIPESUserContactGroupData WHERE UserInstanceID = '"& strUID &"'")

    For Each objItem In colItems
      oFiletxt.WriteLine("ExternalURL: " & objItem.ExternalURL)
      oFiletxt.WriteLine("GroupID: " & objItem.GroupID)
      oFiletxt.WriteLine("Name: " & objItem.Name)
      If objItem.Name = "GROUP-I-WANT-TO-DELETE" Then
        oFiletxt.WriteLine("Deleting Group:" & objItem.Name)
        objItem.DeleteInstance()
      End If
      oFiletxt.WriteLine("************")
     Next
     oFiletxt.WriteLine(" ")
     oFiletxt.WriteLine("************************************")
     oFiletxt.WriteLine(" ")
    Next
    oFiletxt.Close
     ObtainLCUserInstanceID = true

    Friday, April 10, 2009 3:17 PM