Mnemosyne Posted January 22, 2008 Share Posted January 22, 2008 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 Link to comment Share on other sites More sharing options...
/dev/null Posted January 22, 2008 Share Posted January 22, 2008 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 ... thanksnetdom.exeSample: 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 More sharing options...
Mnemosyne Posted January 22, 2008 Author Share Posted January 22, 2008 netdom.exeSample: netdom remove /d:mydomain mywksta /ud:mydomain\admin /pd:passwordThanks ... 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 More sharing options...
blademonkey Posted January 22, 2008 Share Posted January 22, 2008 that implies that you would be running the script from the machine you're removing, at which point it would no longer be REMOTE. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
/dev/null Posted January 22, 2008 Share Posted January 22, 2008 (edited) 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 ...???? and what keeps you from using @Computer or whatever you like to build the parameters for netdom.exe ?? Edited January 22, 2008 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 More sharing options...
blademonkey Posted January 22, 2008 Share Posted January 22, 2008 ???? and what keeps you from using @Computer or whatever you like to build the parameters for netdom.exe ??nothing, you basically gave the answer. they just have to figure out the rest. ---"Educate the Mind, Make Savage the Body" -Mao Tse Tung Link to comment Share on other sites More sharing options...
Mnemosyne Posted January 23, 2008 Author Share Posted January 23, 2008 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 Link to comment Share on other sites More sharing options...
Danny35d Posted January 23, 2008 Share Posted January 23, 2008 (edited) 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 helpPost 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 January 23, 2008 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Mnemosyne Posted January 23, 2008 Author Share Posted January 23, 2008 thanks danny35d ,,, i found my answer thanks to your help ... Link to comment Share on other sites More sharing options...
Mnemosyne Posted January 23, 2008 Author Share Posted January 23, 2008 Can someone help? when i run this code( i got on autoit) it get this error ... thanksFunc 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 More sharing options...
dmaey2k Posted January 24, 2008 Share Posted January 24, 2008 NP Mnemosyne (whatever that means) - i am a newbie too ... i can't help you, but i have gotten a lot of help from the people on autoit ... chin up and cheerio Link to comment Share on other sites More sharing options...
Mnemosyne Posted January 24, 2008 Author Share Posted January 24, 2008 i will dmaey2k ... thanks ... what is a dmaey2k anyway? ... Link to comment Share on other sites More sharing options...
Danny35d Posted January 24, 2008 Share Posted January 24, 2008 (edited) 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 January 24, 2008 by Danny35d AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Mnemosyne Posted January 24, 2008 Author Share Posted January 24, 2008 i will try that .. thanks Link to comment Share on other sites More sharing options...
Mnemosyne Posted January 25, 2008 Author Share Posted January 25, 2008 i did mention that i was new to the scripting game ... still can't get this to work .. can anyone pleae explain the function calls of this script? thanks Link to comment Share on other sites More sharing options...
Danny35d Posted January 26, 2008 Share Posted January 26, 2008 Did you try adding the domain name? Computer_RemoveFromDomain('DomainName\UserName', 'UserPassword')If this still doesn't work you may not have the necessary permission to removed the computer name from the domain. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Mnemosyne Posted January 28, 2008 Author Share Posted January 28, 2008 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 More sharing options...
Danny35d Posted January 29, 2008 Share Posted January 29, 2008 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. AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line Link to comment Share on other sites More sharing options...
Mnemosyne Posted January 29, 2008 Author Share Posted January 29, 2008 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 More sharing options...
Mnemosyne Posted January 30, 2008 Author Share Posted January 30, 2008 also ... i am simply using the "Call" statement to Call the Function ... is that wrong? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now