Share via


Deleting a Storage Group

Deleting a Storage Group

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The following example deletes a storage group. For more information, see the Introduction to Exchange Store Configuration.

Visual Basic

'//////////////////////////////////////////////////////////////////////////////////
'// Name:       DeleteStorageGroup
'// Purpose:    To delete a storage group
'// Input:      strSGName = contains the name of the storage group to be deleted
'//             strComputerName = contains the name of the Exchange 2000 server
'//
'// Notes:      Dismount is performed automatically when deleted.
'//
'//////////////////////////////////////////////////////////////////////////////////

Public Sub DeleteStorageGroup(ByVal strSGName As String, _
                                   ByVal strComputerName As String)
    On Error Resume Next
    Dim iServer         As New CDOEXM.ExchangeServer
    Dim iStGroup        As New CDOEXM.StorageGroup
    Dim arrStGroup()    As Variant
    Dim strSGUrl        As String
    Dim i               As Integer

    strSGUrl = ""

    ' Bind to the Exchange Server
    iServer.DataSource.Open strComputerName

    ' Set variant array to the ExchangeServer.StorageGroups
    arrStGroup = iServer.StorageGroups

    ' Look for a Storage Group with strSGName name in the StorageGroups array
    For i = 0 To UBound(arrStGroup)
        If InStr(1, UCase(arrStGroup(i)), UCase(strSGName)) <>   0 Then
            strSGUrl = arrStGroup(i)
        End If
    Next
    ' Verify if StorageGroup was found
    If strSGUrl <> "" Then
        ' Bind to the StorageGroup
        iStGroup.DataSource.Open "LDAP://" & iServer.DirectoryServer & "/" & strSGUrl

        ' Delete the StorageGroup
        iStGroup.DataSource.Delete
    End If

    ' Cleanup
    Set iServer = Nothing
    Set iStGroup = Nothing

End Sub

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.