marcsusy Posted November 12, 2013 Share Posted November 12, 2013 I'm trying to rename a computer in a domain and I get the following error: : ==> The requested action with this object has failed.: $rc = $objWMIComputerSystem.Rename($NewComputer,$sPassword,$sUserName)^ ERROR The script is used: $sHost = "HOST" $sDomain = "Domain" $sUserName = "User" $sPassword = "pass" $NewComputer = "NEW_HOST" $objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIComputer = $objSWbemLocator.ConnectServer($sHost, "rootcimv2", $sDomain&""&$sUserName, $sPassword) $objSWbemLocator.Security_.ImpersonationLevel = 3 $objWMIComputerSystem = $objWMIComputer.Get("Win32_ComputerSystem.Name='" &$sHost & "'") $rc = $objWMIComputerSystem.Rename($NewComputer,$sPassword,$sUserName) IF $rc <> 0 then MsgBox(0,"","failed") Else MsgBox(0,"","Successfully renamed") Endif Link to comment Share on other sites More sharing options...
water Posted November 12, 2013 Share Posted November 12, 2013 Add a COM error handler to get better error description. See how to do so in the help file for ObjEvent. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
marcsusy Posted November 13, 2013 Author Share Posted November 13, 2013 Thanks I' ll Tray, Water Link to comment Share on other sites More sharing options...
marcsusy Posted November 13, 2013 Author Share Posted November 13, 2013 I tried this new script at home and it works correctly, but at work it does not work, do not get any errors but does not change the hostname, I get the message failed, not why $strComputer = "HOST" $strNewComputer = "NEWHOST" $strDomainUser = "User" $strDomainPasswd = "pass" $strLocalUser = "HOSTAdminuser" $strLocalPasswd = "passadmin" $oErrorHandler = ObjEvent("AutoIt.Error","ObjErrorHandler") $objWMILocator = ObjCreate("WbemScripting.SWbemLocator") $objWMILocator.Security_.AuthenticationLevel = 6 $objWMIComp = $objWMILocator.ConnectServer($strComputer, _ "rootcimv2", _ $strLocalUser, _ $strLocalPasswd) $objWMICompSys = $objWMIComp.Get("Win32_ComputerSystem.Name='" & $strComputer & "'") $intRC = $objWMICompSys.Rename($strNewComputer, _ $strDomainPasswd, _ $strDomainUser) IF $intRC <> 0 then MsgBox(0,"","Fail") Else MsgBox(0,"","Successfully renamed") Endif Func ObjErrorHandler() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oErrorHandler.description & @CRLF & _ "err.windescription:" & @TAB & $oErrorHandler.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oErrorHandler.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oErrorHandler.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oErrorHandler.scriptline & @CRLF & _ "err.source is: " & @TAB & $oErrorHandler.source & @CRLF & _ "err.helpfile is: " & @TAB & $oErrorHandler.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oErrorHandler.helpcontext _ ) Link to comment Share on other sites More sharing options...
water Posted November 13, 2013 Share Posted November 13, 2013 What is the value of $intRC, @error and @extended after the rename? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
marcsusy Posted November 13, 2013 Author Share Posted November 13, 2013 Water I get the error is $intRC 1323 Link to comment Share on other sites More sharing options...
water Posted November 13, 2013 Share Posted November 13, 2013 According to this documentation it means: ERROR_WRONG_PASSWORD Unable to update the password. The value provided as the current password is incorrect. 1323 (0x52B) My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted November 13, 2013 Share Posted November 13, 2013 I think your problem is described here: "However, you cannot use the method remotely for domain computers."wever, you cannot use the method remotely for domain computers." My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted November 13, 2013 Share Posted November 13, 2013 Google offers a lot of solutions for this problem. One of them can be found here. The AD part can be solved using my AD UDF (for download please check my signature). My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki 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