+ Post New Thread
Page 3 of 6 FirstFirst 123456 LastLast
Results 31 to 45 of 81
Windows 7 Thread, Auto join domain using sysprep - Windows 7 in Technical; Thanks Steve. I'll give it a go and report back...
  1. #31

    Join Date
    Jun 2010
    Location
    England
    Posts
    735
    Thank Post
    89
    Thanked 52 Times in 46 Posts
    Rep Power
    35
    Thanks Steve. I'll give it a go and report back

  2. #32

    Join Date
    Jun 2010
    Location
    England
    Posts
    735
    Thank Post
    89
    Thanked 52 Times in 46 Posts
    Rep Power
    35
    The lines you said work perfect Steve, thanks.
    Problem now is i'm getting error 0 and not joining the domain like others have said, so it's not working ^^

  3. #33

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,731
    Thank Post
    344
    Thanked 520 Times in 488 Posts
    Rep Power
    180
    Quote Originally Posted by ihaveaproblem View Post
    The lines you said work perfect Steve, thanks.
    Problem now is i'm getting error 0 and not joining the domain like others have said, so it's not working ^^
    Did it work before you added those lines? Or wasn't it working before?

    It could be as simple as a command you're trying to do before the delete takes a while to complete, and you're deleting the script before it finishes.

    Aka could put a huge delay in the delete.

    Steve

  4. #34

    Join Date
    Jun 2010
    Location
    England
    Posts
    735
    Thank Post
    89
    Thanked 52 Times in 46 Posts
    Rep Power
    35
    Yup it worked before i added the lines, but now i've deleted the lines and tried again and it still doesnt work, odd.

  5. #35

    Join Date
    Jun 2010
    Location
    England
    Posts
    735
    Thank Post
    89
    Thanked 52 Times in 46 Posts
    Rep Power
    35
    I've took this script from another site and it seems to work, but it doesnt prompt for a computer name or automaticaly restart.
    Do any of you clever script people know if its possible to add the above to this script

    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 = "FABRIKAM"
    strPassword = "ls4k5ywA"
    strUser = "shenalan"

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

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

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

  6. #36

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,731
    Thank Post
    344
    Thanked 520 Times in 488 Posts
    Rep Power
    180
    Quote Originally Posted by ihaveaproblem View Post
    I've took this script from another site and it seems to work, but it doesnt prompt for a computer name or automaticaly restart.
    Do any of you clever script people know if its possible to add the above to this script
    If you actually mean prompting for pc name:

    Code:
    strComputer = UserInput( "Choose a pc name:" )
    Instead of:

    Code:
    Set objNetwork = CreateObject("WScript.Network")
    strComputer = objNetwork.ComputerName
    But isn't this supposed to be an unattended file? :P

    To do a restart you can do it like this:

    Code:
    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate,(Shutdown)}!\\" & _
    strComputer & "\root\cimv2")
    
    Set colOperatingSystems = objWMIService.ExecQuery _
    ("Select * from Win32_OperatingSystem")
    
    For Each objOperatingSystem in colOperatingSystems
    objOperatingSystem.Reboot()
    Next
    Think that should do it!

    If you want the restart a bit shorter, you can use:

    Code:
    Set shellCommand= WScript.CreateObject("WScript.Shell")
    shellCommand.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
    Only issue is things start occuring like if people don't have the shutdown.exe in that place. But if its your own domain just rename where it is.

    Steve

  7. Thanks to Steve21 from:

    ihaveaproblem (8th July 2011)

  8. #37

    Join Date
    May 2011
    Location
    Jus North of London, close but not too close
    Posts
    860
    Thank Post
    191
    Thanked 72 Times in 67 Posts
    Rep Power
    50
    We use a PowerShell script

    We put a SetupComplete.cmd file in the C:\Windows\Setup\Scripts folder which then runs import.ps1 from the c:\windows\system32\sysprep\ folder the cmd also deletes the file as you don't want to leave any sensitive usernames or passwords on the C: drive jus in case.

    The script of the import.ps1 You need to change the parts in red to suit your environment.

    $User = "domain\user"
    $Pass = ConvertTo-SecureString "Password" -AsPlainText -Force
    $Credentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Pass
    add-computer -domainname domainname.local -credential $Credentials

    If you remove the ComputerName part the xml will wait for computer name as it sets up

  9. Thanks to Davit2005 from:

    ihaveaproblem (8th July 2011)

  10. #38

    Join Date
    Jun 2010
    Location
    England
    Posts
    735
    Thank Post
    89
    Thanked 52 Times in 46 Posts
    Rep Power
    35
    Thanks. I will give both a in the morning back at work.
    It is suppose to be unattended... everything but the computer name that is. I want that to prompt me before joining the domain.

    EDIT

    I just tried the line you suggestioned Steve

    strComputer = UserInput( "Choose a pc name:" )
    For me it gives an error saying 'type mismatch: "user input"
    Last edited by ihaveaproblem; 7th July 2011 at 06:24 PM.

  11. #39

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,731
    Thank Post
    344
    Thanked 520 Times in 488 Posts
    Rep Power
    180
    Quote Originally Posted by ihaveaproblem View Post
    Thanks. I will give both a in the morning back at work.
    It is suppose to be unattended... everything but the computer name that is. I want that to prompt me before joining the domain.

    EDIT

    I just tried the line you suggestioned Steve



    For me it gives an error saying 'type mismatch: "user input"
    Oops should be inputbox

    My bad,
    Steve

  12. Thanks to Steve21 from:

    ihaveaproblem (8th July 2011)

  13. #40

    Join Date
    Jun 2010
    Location
    England
    Posts
    735
    Thank Post
    89
    Thanked 52 Times in 46 Posts
    Rep Power
    35
    Sorry to be a pain.
    Both those shutdowns dont seem to work either? I've tried both and copied the text to the end of the script an on the second one shutdown.exe is in the same location it's pointing at.
    Am i doing something wrong?
    Also I plan to copy the delete command at the end as well to delete the script once ran.

  14. #41

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,731
    Thank Post
    344
    Thanked 520 Times in 488 Posts
    Rep Power
    180
    Quote Originally Posted by ihaveaproblem View Post
    Sorry to be a pain.
    Both those shutdowns dont seem to work either? I've tried both and copied the text to the end of the script an on the second one shutdown.exe is in the same location it's pointing at.
    Am i doing something wrong?
    Also I plan to copy the delete command at the end as well to delete the script once ran.
    Well just ran:

    Code:
    Set shellCommand= WScript.CreateObject("WScript.Shell")
    shellCommand.Run "C:\WINDOWS\system32\shutdown.exe -r -t 0"
    And it works fine. So I'm guessing either a typo, or you don't have access on the account you're running to do the command/exe? :P

    You sure you copied it right, and have access to run it? Where are you trying to run the script from? Also are you currently on XP doing it? Or actually on Win7? Just might be fussy and want /r /t instead of -r -t

    Steve

  15. #42

    Join Date
    May 2011
    Location
    Jus North of London, close but not too close
    Posts
    860
    Thank Post
    191
    Thanked 72 Times in 67 Posts
    Rep Power
    50
    Is there any particular reason why you need the shutdown command?

    Are you just using ghost or WDS/SCCM method to deploy images?

    With the way we do sysprep (ghost), something we have found is you need to create a computer account for the machine prior to the machine running the setup part of the rebuild after image but apart from that it seem quite a straight forward task to perform once done a few times.

    Cheers,
    David

  16. #43

    Join Date
    Jun 2010
    Location
    England
    Posts
    735
    Thank Post
    89
    Thanked 52 Times in 46 Posts
    Rep Power
    35
    Thanks. Think i've got this sorted.
    I couldnt get the shutdown script to work... i really dont know why.

    In the end i set my answer file to prompt for a computer name, then the SetComplete.cmd ran the join domain script and also in the setupcompete is the command to do a restart after 1 minute.
    Works good and exactly what I wanted.

  17. #44
    projector1's Avatar
    Join Date
    Nov 2005
    Posts
    461
    Thank Post
    70
    Thanked 1 Time in 1 Post
    Rep Power
    19
    Has anyone Been able to input the join to a domain info into a sysprep file as it does have that functionality and need to call on any cb, batch files?

  18. #45

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,266
    Thank Post
    242
    Thanked 1,575 Times in 1,254 Posts
    Rep Power
    341

    This is how I do it :)

    This is how I run MySysprep2, manually name the workstation and automatically join the domain. I've used this on many networks

    1. From your Windows 7 Pro SP1 disc (volume license) copy the install_Windows 7 PROFESSIONAL.clg file from the \Sources\ folder into: C:\Windows\System32\Sysprep\

    2. Download MySysprep2 here (scroll down the page) and extract MySysprep.exe into: C:\Windows\System32\Sysprep\

    3. Open up Notepad and paste the code below. Save the file as Sysprep.cmd in C:\Windows\System32\Sysprep\

    Code:
    Code:
    @echo off
    mysysprep /oobe /generalize /unattend:c:\windows\system32\sysprep\unattend.xml
    4. Open up Notepad and paste the code below. Save the file as unattend.xml in C:\Windows\System32\Sysprep\

    Code:
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
        <settings pass="oobeSystem">
            <component name="Microsoft-Windows-International-Core" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <InputLocale>en-GB</InputLocale>
                <SystemLocale>en-GB</SystemLocale>
                <UILanguage>en-US</UILanguage>
                <UILanguageFallback>en-GB</UILanguageFallback>
                <UserLocale>en-GB</UserLocale>
            </component>
            <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <OOBE>
                    <HideEULAPage>true</HideEULAPage>
                    <NetworkLocation>Work</NetworkLocation>
                    <ProtectYourPC>1</ProtectYourPC>
                </OOBE>
                <UserAccounts>
                    <LocalAccounts>
                        <LocalAccount wcm:action="add">
                            <Password>
                                <Value>dwBlAGwAYwBvAG0AZQBQAGEAcwBzAHcAbwByAGQA</Value>
                                <PlainText>false</PlainText>
                            </Password>
                            <Description>Local User</Description>
                            <DisplayName>LOCAL USERNAME</DisplayName>
                            <Group>administrators</Group>
                            <Name>LOCAL USERNAME</Name>
                        </LocalAccount>
                    </LocalAccounts>
                </UserAccounts>
                <TimeZone>GMT Standard Time</TimeZone>
                <RegisteredOrganization>SCHOOL NAME</RegisteredOrganization>
                <RegisteredOwner>SCHOOL NAME</RegisteredOwner>
                <ShowWindowsLive>false</ShowWindowsLive>
            </component>
        </settings>
        <settings pass="specialize">
            <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <ProductKey>FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4</ProductKey>
                <ComputerName>%Please input a computer name%</ComputerName>
                <RegisteredOrganization>SCHOOL NAME</RegisteredOrganization>
                <RegisteredOwner>SCHOOL NAME</RegisteredOwner>
                <ShowWindowsLive>false</ShowWindowsLive>
                <TimeZone>GMT Standard Time</TimeZone>
            </component>
            <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="x86" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                <Identification>
                    <Credentials>
                        <Domain>DOMAIN.DOMAIN</Domain>
                        <Username>ADMINISTRATOR</Username>
                        <Password>PASSWORD</Password>
                    </Credentials>
                    <JoinDomain>DOMAIN.DOMAIN</JoinDomain>
                </Identification>
            </component>
        </settings>
        <cpi:offlineImage cpi:source="catalog:c:/windows/system32/sysprep/install_windows 7 professional.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
    </unattend>
    You just need to search/change the following:

    LOCAL USERNAME - A suitable local account, such as for teachers when they're working from home
    SCHOOL NAME - Enter your school name
    FJ82H-XT6CR-J8D7P-XQJJ2-GPDD4 - Default KMS key. You can change this for a MAK key (optional)
    %Please input a computer name% - Leave this as it is!
    DOMAIN.DOMAIN - Enter your FQDN (Fully Qualified Domain Name). This is a must!
    ADMINISTRATOR - Specify the domain administrator account (if renamed)
    PASSWORD - Specify the domain administrator password

    Run the Sysprep.cmd file with admin rights and Sysprep will start as normal. When the computer reboots, it'll prompt you for a computer name (of your choice) then join your domain. Windows 7 is then ready to be activated with a KMS server or will activate within 3 days with your MAK (depending what you entered).

    The automatically created computer object will be added to the Computers container where you can move it as required. You can specify an OU, but as all networks are different, I've tried to keep this as simple as possible!

    I hope this helps some of you! Good luck with your Windows 7 deployment!

  19. 6 Thanks to Michael:

    CBlunt (8th May 2014), Jamers (28th June 2012), LordNewton (23rd February 2012), mrstrong (11th July 2013), sidewinder (19th September 2012), speckytecky (19th January 2012)

SHARE:
+ Post New Thread
Page 3 of 6 FirstFirst 123456 LastLast

Similar Threads

  1. Replies: 0
    Last Post: 17th February 2011, 02:57 PM
  2. Windows 7 PC won't join server 2008 Domain
    By speckytecky in forum Windows 7
    Replies: 1
    Last Post: 30th September 2010, 12:22 PM
  3. XP SP3 Sysprep Domain Join 'weirdness'
    By _techie_ in forum Windows
    Replies: 2
    Last Post: 20th July 2010, 01:02 PM
  4. Script to join new domain
    By THERADIOTUBBY in forum Windows Server 2008 R2
    Replies: 4
    Last Post: 2nd July 2010, 08:32 AM
  5. No Domain Join during Setup
    By Nick_Parker in forum Windows 7
    Replies: 19
    Last Post: 24th August 2009, 01:13 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •