Jump to content
Sign in to follow this  
knet74

delete an active directory group

Recommended Posts

knet74

Hi there...

Is there anyone how know how to delete an active directory group by using something like this:

$DeleteGrp = ObjGet("WinNT://DOMAIN/" &$GroupName)

$DeleteGrp.Delete ("group",$GroupName)

Share this post


Link to post
Share on other sites
PsaltyDS

Hi there...

Is there anyone how know how to delete an active directory group by using something like this:

$DeleteGrp = ObjGet("WinNT://DOMAIN/" &$GroupName)

$DeleteGrp.Delete ("group",$GroupName)

You could try it like this, which I got from here. (Untested):

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler

$strPath = "DC=your,DC=domain,DC=com" ; LDAP binding path.
$strParent = "OU=TestParent" ; Parent OU of group
$strDelete = "CN=TestGroup" ; Group to delete.

; Bind to the object.
$objADAM = ObjGet("LDAP://" & $strParent & "," & $strPath)
If IsObj($objADAM) Then
    ; Delete Group.
    $objADAM.Delete ("group", $strDelete)
Else
    MsgBox(16, "Error", "$objADAM is not an object: LDAP bind failed.")
EndIf


; This is my custom error handler
Func MyErrFunc()
    $HexNumber = Hex($oMyError.number, 8)
    MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _
            "Number is: " & $HexNumber & @CRLF & _
            "Windescription is: " & $oMyError.windescription)
    Return SetError(1) ; something to check for when this function returns
EndFunc   ;==>MyErrFunc

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×