Jump to content

Another Active Directory question


BoogY
 Share

Recommended Posts

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

Link to comment
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 ??

Link to comment
Share on other sites

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
Link to comment
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 ?

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...