| |
bryhud
Posts: 1
Score: 0
Joined: 11/29/2006
Status: offline
|
I am having trouble with the script below, I am hoping to rename a PC then add it to the domain. I am able to reset the PC name successfully but then receive an erro Line: 36 Char: 9 Error: Invalid methos parameter9s) Code: 8004102F Source: SWbenObjectEx I Ok thru the message and reboot the PC and the name takes, however it also appears to successfuly change the name of the PC in AD. The PC was already added to the domain with a generic name, I don't know if this is causing the problem? Or if there is a problem with the coding. I am very new to this and have searched google for the error code and found little help Here is the code, any help would be greatly appreciated. Thanks Name = InputBox("Enter the new computer name below and click OK to continue","Rename: Step 1") Password = "password" Username = "username" Set objWMIService = GetObject("Winmgmts:root\cimv2") ' Call always gets only one Win32_ComputerSystem object. For Each objComputer in _ objWMIService.InstancesOf("Win32_ComputerSystem") Return = objComputer.rename(Name,Password,User) If Return <> 0 Then WScript.Echo "Rename failed. Error = " & Err.Number Else WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect" End If Next DomainName = domain DomainPassword = "password" DomainUsername = "username" Set objWMIService = GetObject("Winmgmts:root\cimv2") ' Call always gets only one Win32_ComputerSystem object. For Each objComputer in _ objWMIService.InstancesOf("Win32_ComputerSystem") Return = objComputer.JoinDomainOrWorkgroup(DomainName,DomainPassword,DomainUsername) If Return <> 0 Then WScript.Echo "Rename failed. Error = " & Err.Number Else WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect" End If Next
|
|