Google Reviews
If you find this content or our services useful, please leave us a review.

Other Posts in this Series:

This post provides a simple example of how we can use ADSI to delete an AD group.

#OU containing the AD group
$adGroupOU="OU=Application,OU=Groups,DC=alkanesolutions,DC=co,DC=uk"

#AD group name
$addADGroup = "CN=alkane_ad_group"

#Full distinguished name of AD group		
$distinguishedName = "$addADGroup,$adGroupOU"

#check if exists
$group = ([ADSISearcher] "(distinguishedName=$distinguishedName)").FindOne()

if ($group -ne $null)
{		
    #delete AD group
    $adGroupObj = [ADSI]"LDAP://$adGroupOU"
    $adGroupObj.Delete("Group",$addADGroup)
}
Use ADSI to Delete an AD Group
Comments have now been disabled. If you have a question to ask about this post please ask the community!