Sign in to follow this  
Followers 0
BoogY

Another Active Directory question

12 posts in this topic

HELLO THERE EVERYONE :D

I have another AD question :

How can i delete (remove) a PC from AD, OU ???

I dit try with netdom remove but not working.

Thanks a lot.

Share this post


Link to post
Share on other sites



Func deleteFromDomain($adUsername,$adPassword)
        
    ;------------------------------------------------------------------------------
    ; les variables pour la commande netdom.Execute
    ;------------------------------------------------------------------------------
    $DomUser        = $adUsername
    $DomPwd         = $adPassword
    $CompName       = GUICtrlRead($txtTFS)
    ;------------------------------------------------------------------------------
    ; Delete the computer from the $oucomp
    ;------------------------------------------------------------------------------
    $delete = RunWait(@ComSpec & " /c netdom.exe remove /domain:ADACV "& $CompName & _
                " /userd:ADACV\"& $DomUser & " /passwordd:"& $DomPwd,"",@SW_HIDE)
    ;------------------------------------------------------------------------------
    ; Afficher le resultat de la commande
    ;------------------------------------------------------------------------------
    If $delete = 0 Then
;~      MsgBox(0,"ERREUR","Le pc n'as pas été supprimé de domain ADACV" & @CRLF & "Erreur : " & @error)
        UpdateProgressText("ERREUR de suppression du domain ADACV  [PC] : " & $CompName)
    Else
;~      MsgBox(0,"Succès","Le pc " & $CompName & " a été supprimé du domain ADACV")
        UpdateProgressText("L'ordinateur " & $CompName & _
        " a été supprimé avec succès du domain ADACV")
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

this is the help from microsoft :

Example 8: Remove a Workstation or Member Server from a Domain

To remove mywksta from the mydomain domain and make the workstation a part of a workgroup, type the following at the command prompt:

netdom remove /d:mydomain mywksta /ud:mydomain\admin /pd:password

what about @ComSpec /c ??

Share this post


Link to post
Share on other sites

actualy it disables the workstation its not deleting it from the domain or the OU

Share this post


Link to post
Share on other sites

You're making the exact same mistakes as in your previous topic. First try the command in the run box, if it works, translate into AutoIt.

Also, using running @ComSpec & "/c notepad.exe" is the same as running "notepad.exe". See the similarities here?

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

actualy it disables the workstation its not deleting it from the domain or the OU

Hi,

the disabling is by design.

If you want to join the computer again, his SID in domain wouldn't change.

DSRM is your friend, if you really want to delete the computeraccount. Open cmd and type dsrm /? for syntax.

Or you may look here as well:

http://technet.microsoft.com/en-us/library/cc776784(WS.10).aspx

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites

its what i'm trying to do now bur i dont want to delete everithing cause am at work ...

i have this syntax : dsrm.exe -subtree -exclude -noprompt -d DOMAIN -u USER -p PASSSWORD CN=COMPUTER,OU=CRENOL,OU=DG,OU=DF,OU=Computers,OU=ACV,DC=ADACV,DC=AD,DC=ETAT,DC=CH

will it delete juste the computer or everithing in the OU CRENOL ?

Share this post


Link to post
Share on other sites

its what i'm trying to do now bur i dont want to delete everithing cause am at work ...

i have this syntax : dsrm.exe -subtree -exclude -noprompt -d DOMAIN -u USER -p PASSSWORD CN=COMPUTER,OU=CRENOL,OU=DG,OU=DF,OU=Computers,OU=ACV,DC=ADACV,DC=AD,DC=ETAT,DC=CH

will it delete juste the computer or everithing in the OU CRENOL ?

Hi,

For deleting one computer:

dsrm "CN=COMPUTER,OU=CRENOL,OU=DG,OU=DF,OU=Computers,OU=ACV,DC=ADACV,DC=AD,DC=ETAT,DC=CH" -noprompt -d DOMAIN -u USER -p PASSWORD

You use -subtree for deleting Organizational Units and its structure beneath. You may use it to delete all computerobjects in an OU.

;-))

Stefan

Share this post


Link to post
Share on other sites

thanks man your realy a saver :D thanks a lot for your help

Share this post


Link to post
Share on other sites

it work :D thanks agen

And for Manadar : i get the picture for @ComSpec THANKS A LOT

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  
Followers 0