Jump to content

Recommended Posts

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

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

 

Posted
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 _
            )
Posted

What is the value of $intRC, @error and @extended after the rename?

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

 

Posted

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

 

Posted

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

 

Posted

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

 

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
×
×
  • Create New...