Wsname question, KACE?
Hi!
I have a question about wsname. I have a almost working batch script with wsname, script rename the computer. The problem is if the computer name already is in the AD, the script/wsname not working. It said something about the account is already exists. But if I delete computer name in AD before installation is working fine. Is there a SIMPLE solution to fix this, maybe a commando or something?
Many thx, Janne.
Answers (2)
If the machine is already in the domain and the new name is already in the domain this will occur. Do not precreate the new name when renaming a machine already in the domain. the only other thing is to create a script that remove the machine, rename the machine and rejoin it to the domain. Since you are using the k2000 you want to rename the machine before you join it
This is a script to rename a machine in the domain to a existing name in the domain
start /wait Wmic computersystem where name="%computername%" call unjoindomainorworkgroup
start /wait wmic.exe computersystem where "caption='%computername%'" rename newname
start /wait cscript.exe -b c:\windows\w2d\join_domain.vbs tmccacad.tmcc.edu domainuser password domainserverIP
shutdown -r -t 1
join_domain.vbs file:
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
Const ACCT_DELETE = 4
Const WIN9X_UPGRADE = 16
Const DOMAIN_JOIN_IF_JOINED = 32
Const JOIN_UNSECURE = 64
Const MACHINE_PASSWORD_PASSED = 128
Const DEFERRED_SPN_SET = 256
Const INSTALL_INVOCATION = 262144
If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then
WScript.Quit
Else
strDomain = WScript.Arguments.Item(0)
strUser = WScript.Arguments.Item(1)
strPassword = WScript.Arguments.Item(2)
'set DNS IP address
If WScript.Arguments.Count = 4 Then
strDNSIP = WScript.Arguments.Item(3)
Set objShell = CreateObject("WScript.shell")
objShell.Run "netsh int ip set dns ""local area connection"" static "& _
strDNSIP &" primary",0,0
End If
End If
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & _
"\root\cimv2:Win32_ComputerSystem.Name='" _
& strComputer & "'")
ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, _
strDomain & "\" & strUser, _
NULL, _
JOIN_DOMAIN+ACCT_CREATE)