Jump to content

Domain Admin


Recommended Posts

Does anyone know where i can find a script to remotely remove a computer from the domain? i am a domain admin and i also have the local admin passwords ... thanks

netdom.exe

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

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

netdom.exe

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

Thanks ... but what i am looking for is a more generic script to use ... netdom forces me to enter the workstation id etc ... i need something that with perhaps use the @Computer entry thus allowing me to use it on any computer ...

Link to comment
Share on other sites

Thanks ... but what i am looking for is a more generic script to use ... netdom forces me to enter the workstation id etc ... i need something that with perhaps use the @Computer entry thus allowing me to use it on any computer ...

???? :D and what keeps you from using @Computer or whatever you like to build the parameters for netdom.exe ??

Edited by /dev/null

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

i tried using the netdom.exe with the @computer .. that is why i used it for an example ... but it keeps giving an error when i run the command from the script ... do i have to use runwait or something ... thanks for the help

Post the script or the section of the script using Netdom.exe so we can help you. Also look at this link from xwing1978 it have the following WMI functions:

Computer_Rename( $sComputerName, $sLocalUser, $sPassword )

Computer_AddToDomainOrWorkgroup( $sDomain, $sDomainUsername, $sPassword )

Computer_RemoveFromDomain( $sDomainUsername, $sPassword )

Computer_MemberOfDomainOrWorkgroup( )

Note: These function may only work in windows xp and windows 2003

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Can someone help? when i run this code( i got on autoit) it get this error ... thanks

Func Computer_RemoveFromDomain( $sDomainUsername, $sPassword )

Local $objWMIService, $objComputer

;Create a WMI object

$objWMIService = ObjGet( "Winmgmts:root\cimv2" )

;Verify the object was created

If IsObj( $objWMIService ) Then

For $objComputer in $objWMIService.InstancesOf( "Win32_ComputerSystem" )

;Remove the computer from the domain

$sReturn = $objComputer.UnjoinDomainOrWorkgroup( $sPassword, $sDomainUsername, 0 )

If $sReturn <> 0 Then

If IsDeclared( "sFileName" ) Then FileWriteLine( $sFileName, "System_Computer_Rename: Unable to rename the computer, possible Error: " &$sReturn &". - ScriptLine Number: " &@ScriptLineNumber )

SetError( 1 )

Return 0

EndIf

Next

Else

;Object was not created

If IsDeclared( "sFileName" ) Then FileWriteLine( $sFileName, "System_Computer_Rename: The WMI object was not created. - ScriptLine Number: " &@ScriptLineNumber )

SetError( 1 )

Return 0

EndIf

Return 1

EndFunc

Errors:

E:\domainremoval.au3(15,64) : WARNING: $sFileName: possibly used before declaration.

If IsDeclared( "sFileName" ) Then FileWriteLine( $sFileName,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\domainremoval.au3(15,64) : ERROR: $sFileName: undeclared global variable.

If IsDeclared( "sFileName" ) Then FileWriteLine( $sFileName,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

E:\domainremoval.au3 - 1 error(s), 1 warning(s)

yes i am a NEWBIE

Link to comment
Share on other sites

Just added to the function a local variable and called $sFileName

Func Computer_RemoveFromDomain($sDomainUsername, $sPassword)
    Local $sFileName
    Local $objWMIService, $objComputer

    ;Create a WMI object
    $objWMIService = ObjGet("Winmgmts:root\cimv2")
    ;Verify the object was created
    If IsObj($objWMIService) Then
        For $objComputer In $objWMIService.InstancesOf("Win32_ComputerSystem")
            ;Remove the computer from the domain
            $sReturn = $objComputer.UnjoinDomainOrWorkgroup($sPassword, $sDomainUsername, 0)
            If $sReturn <> 0 Then
                FileWriteLine($sFileName, "System_Computer_Rename: Unable to rename the computer, possible Error: " & $sReturn & ". - ScriptLine Number: " & @ScriptLineNumber)
                SetError(1)
                Return 0
            EndIf
        Next
    Else
        ;Object was not created
        FileWriteLine($sFileName, "System_Computer_Rename: The WMI object was not created. - ScriptLine Number: " & @ScriptLineNumber)
        SetError(1)
        Return 0
    EndIf
    Return 1
EndFunc   ;==>Computer_RemoveFromDomain
Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

this is an example of your script ... i only changed the top line .. is that correct?

Func Computer_RemoveFromDomain( domain\myname, password )

Local $sFilename

Local $objWMIService, $objComputer

;Create a WMI object

$objWMIService = ObjGet( "Winmgmts:root\cimv2" )

;Verify the object was created

If IsObj( $objWMIService ) Then

For $objComputer in $objWMIService.InstancesOf( "Win32_ComputerSystem" )

;Remove the computer from the domain

$sReturn = $objComputer.UnjoinDomainOrWorkgroup( $sPassword, $sDomainUsername, 0 )

If $sReturn <> 0 Then

If IsDeclared( "sFileName" ) Then FileWriteLine( $sFileName, "System_Computer_Rename: Unable to rename the computer, possible Error: " &$sReturn &". - ScriptLine Number: " &@ScriptLineNumber )

SetError( 1 )

Return 0

EndIf

Next

Else

;Object was not created

If IsDeclared( "sFileName" ) Then FileWriteLine( $sFileName, "System_Computer_Rename: The WMI object was not created. - ScriptLine Number: " &@ScriptLineNumber )

SetError( 1 )

Return 0

EndIf

Return 1

EndFunc

Link to comment
Share on other sites

Can you show the script that your are working on it? or show how are you a calling Computer_RemoveFromDomain()? of course you can change show you script with a fake password.

Danny ... maybe i am going about this the wrong way ... what i want to do is to automatically remove any computer from the domain .... let's say that the domain name is "saturn" ... i want to remove the computer from "saturn" using a script ...

do i still ahve to use a program like netdom.exe or can a script by itself do it ... thanks

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...