water Posted April 5, 2016 Author Posted April 5, 2016 De nada My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted April 5, 2016 Posted April 5, 2016 (edited) Ok got passed the AD Open issue Now I am having an issue with JoinDomain Here is what it looks like $test = _AD_JoinDomain(@ComputerName, "", "",Default,32, $newPCName) I added this to the top of my script _AD_ErrorNotify(2) I get a Com Error Encountered $newPCName is declared earlier in the script With some information probably missing - what do you think I could be doing wrong water? Edited April 5, 2016 by OrangeCoder
OrangeCoder Posted April 5, 2016 Posted April 5, 2016 forgot to turn on notify me of replies - so now I have
water Posted April 5, 2016 Author Posted April 5, 2016 You do call _AD_Open in your script before calling _AD_JoinDomain? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
water Posted April 5, 2016 Author Posted April 5, 2016 BTW: I will be on vacation for the next two weeks. So my responses might be a bit slow. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted April 5, 2016 Posted April 5, 2016 yes sir I do an _AD_Open before hand - someplace fun I hope ?
water Posted April 6, 2016 Author Posted April 6, 2016 What is the value of @error and @extended after _AD_Open? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted April 11, 2016 Posted April 11, 2016 Hey Water ! not sure if you are back from vacation I have a rhetorical question but I'll ask anyway lol when adding a computer to a domain - before I run _AD_JoinDomain - I need to run _AD_CreateComputer ?
water Posted April 11, 2016 Author Posted April 11, 2016 Still on vacation 😎 IIRC you can specify the computer name and OU when joining the domain. _AD_CreateComputer allows granular permission settings. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted April 11, 2016 Posted April 11, 2016 Hey Water - think I may have realized what my issue is What if I wanted to specify that a newly added computer be placed into a container and not an OU ? Would _Ad_JoinDomain be applicable for that ?
water Posted April 11, 2016 Author Posted April 11, 2016 I'm not sure you can place a computer in a container, never tried. But a computer is a container itself. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted April 11, 2016 Posted April 11, 2016 I think you can - by default we have a container labeled - Computers and whenever you manually add a computer to our domain - it always goes to that container labeled Computers Kept trying to make this script work- banging my head against the wall! lol
water Posted April 11, 2016 Author Posted April 11, 2016 Will have a look at the UDF when I return from vacation in about two weeks. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted April 11, 2016 Posted April 11, 2016 Hey water - another question So I have what I think is a working script that names and domains a computer My PC does get renamed correctly I get a message saying its been added to the domain When I search AD - I do see it in some odd OU but it's there however when I reboot the computer The Windows Settings haven't been changed for it sign onto the domain - did I miss a step somewhere ?
water Posted April 12, 2016 Author Posted April 12, 2016 You need to provide more information. Post your script. What does "odd OU" mean? What does "Windows settings have not been charged" mean? What do you expect and what do you get? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
OrangeCoder Posted April 12, 2016 Posted April 12, 2016 sorry water - let me let the coffee kick in and I'll get that posted
OrangeCoder Posted April 12, 2016 Posted April 12, 2016 expandcollapse popup#RequireAdmin #include <AD.au3> DriveMapAdd("Z:","\\serverpath\apps\devicesetup",0,"DOMAIN\user.name","password") $file = FileOpen("Z:\dic.txt", 0) $FileContent = FileRead($file) FileClose($file) DriveMapDel ("Z:") $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") $colSMBIOS = $objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure") For $objSMBIOS in $colSMBIOS ;ConsoleWrite("Serial Number: " & $objSMBIOS.SerialNumber & @CRLF) ;ConsoleWrite("Asset Tag: " & $objSMBIOS.SMBIOSAssetTag & @CRLF) Next $serial = StringTrimLeft($objSMBIOS.SerialNumber, 4) $newPCName = $FileContent & $serial Func _RenameComputer($sCompName, $sUserName = "", $sPassword = "") ;Uses WMI Win32_ComputerSystem Local $oMyError = ObjEvent("AutoIt.Error", "_ComError") ;COM Error Handler #forceref $oMyError Local $objWMIService = ObjGet("winmgmts:\root\cimv2") If @error Then Return SetError(1, 0, 0) EndIf For $objComputer In $objWMIService.InstancesOf("Win32_ComputerSystem") Local $oReturn = $objComputer.Rename($sCompName, $sPassword, $sUserName) If $oReturn <> 0 Then Return SetError(2, 0, 0) Else Return 1 EndIf Next EndFunc ;==>_RenameComputer Func _ComError($oMyError) ;COM Error function defined in COM Error Handler used in COM functions. SplashOff() BlockInput(0) ;Enable the Keyboard and Mouse. MsgBox(16, "AutoItCOM ERROR!", "COM Error Intercepted!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) EndFunc ;==>_ComError _RenameComputer($newPCName) ;The new computer's name is "New-Comp." _AD_Open("domain\user.name", "password", "DC=domain,DC=domain1,DC=domain2,DC=domain3,DC=domain4", "full domain put together here") sleep(3000) ; Join the computer to the domain Global $iValue = _AD_JoinDomain(@ComputerName,"","","",2,$newPCName) If $iValue = 1 Then MsgBox(64, "Active Directory Functions - Example 1", "Computer '" & $newPCName & "' successfully joined. Please reboot the computer") ElseIf @error = 1 Then MsgBox(64, "Active Directory Functions - Example 1", "Computer account for '" & $newPCName & "' does not exist in the domain") ElseIf @error = 3 Then MsgBox(64, "Active Directory Functions - Example 1", "WMI object could not be created. @extended=" & @extended) ElseIf @error = 4 Then MsgBox(64, "Active Directory Functions - Example 1", "Computer '" & $newPCName & "' is already a member of the domain") ElseIf @error = 5 Then MsgBox(64, "Active Directory Functions - Example 1", "Joining computer '" & $newPCName & "' to the domain was not successful. @extended=" & @extended) Else MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory") EndIf ; Close Connection to the Active Directory _AD_Close()
OrangeCoder Posted April 18, 2016 Posted April 18, 2016 Hey water - just wanted to check in and see if maybe you are on vacation still ?
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