Solved sysprep computername

i486dx266

New member
Local time
5:26 PM
Messages
8
Windows 7 Pro x64 SP1. Trying to create image using WAIK and sysprep. Everything working fine except this: Want sysprep to prompt for computername during firstboot. Seems to work fine. Computer reboots and logs in as local admin. Checking and can confirm it is joined to the domain with computername given during firstboot. However, when logging on with a domain account i get this error: "the security database on the server does not have a computer account for this workstation trust" and when checking AD it is registered with a generic "WIN-g7ek58blabla" name instead of the given name. Here's the strange thing: When putting "<ComputerName>*</ComputerName>" in unattend.xml to make generic computername sysprep works just fine... no errors on login. Ideas?
 

My Computer

OS
Windows 7 Pro x64
Here's my unattend.xml and below the joindomain.vbs

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="generalize">
<component name="Microsoft-Windows-Security-SPP" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipRearm>1</SkipRearm>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Path>net user administrator /active:no</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
<component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CopyProfile>false</CopyProfile>
<ShowWindowsLive>false</ShowWindowsLive>
<TimeZone>Romance Standard Time</TimeZone>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UILanguage>en-US</UILanguage>
<SystemLocale>nb-NO</SystemLocale>
<UserLocale>nb-NO</UserLocale>
<InputLocale>nb-NO</InputLocale>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="blabla" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoLogon>
<Password>
<Value>blabla==</Value>
<PlainText>false</PlainText>
</Password>
<Enabled>true</Enabled>
<LogonCount>1</LogonCount>
<Username>admin</Username>
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>cscript //b c:\windows\system32\slmgr.vbs /ipk xxxx-xxxx-xxxx-xxxx-xxxx</CommandLine>
<Order>1</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>cscript //b c:\windows\system32\slmgr.vbs /ato</CommandLine>
<Order>2</Order>
<RequiresUserInput>false</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>c:\temp\scripts\JoinDomain.vbs</CommandLine>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<NetworkLocation>Work</NetworkLocation>
<ProtectYourPC>1</ProtectYourPC>
</OOBE>
<UserAccounts>
<AdministratorPassword>
<Value>blabla</Value>
<PlainText>false</PlainText>
</AdministratorPassword>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>blabla==</Value>
<PlainText>false</PlainText>
</Password>
<Description>Local Administrator</Description>
<Group>Administrators</Group>
<Name>Admin</Name>
<DisplayName>Admin</DisplayName>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<RegisteredOrganization>RegisteredOrganization</RegisteredOrganization>
<RegisteredOwner>NO</RegisteredOwner>
</component>
</settings>
<cpifflineImage cpi:source="catalog:c:/sw_dvd5_win_pro_7w_sp1_64bit_english_-2_mlf_x17-59279/sources/install_windows 7 professional.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

----------------------------------------------------------------
Call DoSomething

Sub DoSomething

Dim strPassword
Dim strDomain
Dim strUser

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

strDomain = "domain.name"
strUser = "uid"

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonat e}!\\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")

Do
strPassword = InputBox("Enter password to join domain:", "Join to Domain", "password")
If strPassword = "" Then Exit Sub

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strDomain & "\" & strUser, NULL, JOIN_DOMAIN + ACCT_CREATE)

If ReturnValue = 1326 Then
MsgBox "Logon failure: unknown username or bad password."
End If

If ReturnValue <> 1326 Then Exit Do
Loop

If ReturnValue = 5 Then
MsgBox "Access is denied. Run from an elevated command prompt."
Exit Sub
ElseIf ReturnValue = 87 Then
MsgBox "The parameter is incorrect."
Exit Sub
ElseIf ReturnValue = 110 Then
MsgBox "The system cannot open the specified object."
Exit Sub
ElseIf ReturnValue = 1323 Then
MsgBox "Unable to update password."
Exit Sub
ElseIf ReturnValue = 1355 Then
MsgBox "The specified domain does not exist or could not be contacted."
Exit Sub
ElseIf ReturnValue = 2224 Then
MsgBox "The account already exists."
Exit Sub
ElseIf ReturnValue = 2691 Then
MsgBox "The machine is already joined to the domain."
Exit Sub
ElseIf ReturnValue = 2692 Then
MsgBox "The machine is not currently joined to the domain."
Exit Sub
End If

If ReturnValue = 0 Then
If MsgBox("Domain joined successfully. Restart machine?", vbQuestion + vbYesNo) = vbYes Then
Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
For Each OpSys in OpSysSet
OpSys.Reboot()
Next
Else
'Just quit
End If
End If

End Sub

 

My Computer

OS
Windows 7 Pro x64
After changing the name during firstboot, did you reboot for the change to take effect? If you look in the UI it will have "changed", but until a reboot (if you're prompting for a name), it will still be the sysprep name. Unless setup itself changes the name (which is done pre-boot), you *must* reboot before joining a domain.
 

My Computer

Computer type
PC/Desktop
Computer Manufacturer/Model Number
Custom
OS
Windows 10 Pro x64
CPU
Intel Core i7 4790K @ 4.5GHz
Motherboard
Asus Maximus Hero VII
Memory
32GB DDR3
Graphics Card(s)
Nvidia GeForce GTX970
Sound Card
Realtek HD Audio
Screen Resolution
1920x1200
Hard Drives
1x Samsung 250GB SSD
4x WD RE 2TB (RAIDZ)
PSU
Corsair AX760i
Case
Fractal Design Define R4
Cooling
Noctua NH-D15
Yes, there is a prompt for a name during firstboot. Tis is during the sysprep process. It auto logs in ad local admin, we do some other stuff, then reboot. When logging in it still complains about the issue. We will drop this and go for generic names, which does work. We have no time to error seek this issue, but thanks for the help anyway :-)
 

My Computer

OS
Windows 7 Pro x64
Back
Top