Win 10 Unattend prompt for computer name and join domain

    General discussion

  • We have a 3rd party vendor who needs to be able to apply an image without knowing what the computer is going to be named in the future.  When we get it back, it need to boot up and prompt for computer name and then join the domain.  

    With Windows 7, we would have it prompt for computer name during OOBE and then auto logon as a local account.  From there, a firstLogonCommands in unattend.xml to run a cmd script that joins the domain using this powershell command.

    Powershell.exe -command $pass = convertto-securestring "**********" -asplaintext -force;$domaincred = new-object 'domain\user',$pass;add-computer -credential $domaincred -domainname 'domainname'

    Windows 10 no longer allows for a computer name prompt in the OOBE.  The only way the sysprep domain join works right is if you specify a specific computer name in unattend.xml.  If you leave it blank or make it *, it'll join the domain with one random name, then rename the computer to "desktop-random", breaking the domain trust.  

    The only solution I've found goes like this.

    1. Unattend does not join the domain
    2. It does not specify a computer name
    3. It does specify a local administrator
    4. It auto logs on as that local administrator
    5. It runs RenameComputerAndJoinDomain.cmd script using firstlogoncommands in unattend.xml
    6. RenameComputerAndJoinDomain.cmd  prompts for a computer name then runs a powershell command to rename the computer and join the domain


    set /p PCNAME= New PC Name (15 char limit):
    Powershell -command $pass = convertto-securestring "**********" -asplaintext -force;$domaincred = new-object 'domain\user',$pass;add-computer -credential $domaincred -domainname '' -newname %PCNAME%
    shutdown -r -t 180
    unattend.xml (for reference)
    <settings pass="oobeSystem">
      <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="" xmlns:xsi="">
            <LocalAccount wcm:action="add">
              <Description>local admin</Description>
          <SynchronousCommand wcm:action="add">
          <Description>Post Config</Description>

    I'm convinced this is the only way to accomplish a domain join after name prompt without setting the unattend.xml files before first boot.

    Friday, February 24, 2017 10:16 PM

All replies

  • Hi Mike Plichta,

    Thanks for sharing. It would be very useful as a reference for the person who will come across the similar case in the near future.

    The "Computername" option in unattend file has been decreased for Windows 10. Someone else have shared the similar resolution, too.

    Script to inject COMPUTERNAME variable in to sysprep process for Windows 10
    Unattend.xml and Windows 10

    Best regards

    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact

    Monday, February 27, 2017 2:10 AM
  • Thank you, here's my solution.

                    <SynchronousCommand wcm:action="add">
                        <CommandLine>ipconfig /registerdns</CommandLine>
                    <SynchronousCommand wcm:action="add">
                        <Description>Join Domain</Description>
                        <CommandLine>CMD /C &quot;powershell add-computer -domainname domain.wan -cred (get-credential domain.wan\todomainuser) -newname (Read-Host \&quot;PC new name\&quot;) -passthru -verbose;sleep 8&quot;</CommandLine>
                    <SynchronousCommand wcm:action="add">
                        <CommandLine>CMD /C echo n | gpupdate /force</CommandLine>
                        <Description>gpupdate /force</Description>
                    <SynchronousCommand wcm:action="add">
                        <CommandLine>wuauclt /resetauthorization /detectnow</CommandLine>
                        <Description>Windows Update</Description>

    Don't forget to change domain.wan\todomainuser to yours.
    • Edited by АБВ Tuesday, January 30, 2018 2:52 PM
    Tuesday, January 30, 2018 2:51 PM