Skip to content

Deleting Business Units

The following code sample deletes a Business Unit.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

# Bind to 'My Unit' Business Unit
$businessUnitsPath = $admService.Backend.GetConfigurationContainerPath(
    "BusinessUnits")
$businessUnitsPathObj = New-Object "Softerra.Adaxes.Adsi.AdsPath" `
    $businessUnitsPath
$myBusinessUnitAdsPath = $businessUnitsPathObj.CreateChildPath("CN=My Unit")
$myBusinessUnit = $admService.OpenObject($myBusinessUnitAdsPath, $NULL, $NULL, 0)

# Delete the Business Unit
$myBusinessUnit.DeleteObject("ADM_DELETEOBJECTFLAGS_AUTO")

See also