Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Rename PC script error

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,40222
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Rename PC script error
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Rename PC script error - 11/29/2006 3:42:13 PM   
  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
 
 
Post #: 1
 
 RE: Rename PC script error - 11/29/2006 6:46:40 PM   
  ginolard


Posts: 1082
Score: 21
Joined: 8/10/2005
Status: offline
Return = objComputer.rename(Name,Password,User)

That line would appear to be wrong as you declare the variable USERNAME but then pass one called USER


_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to bryhud)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Rename PC script error Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts