+ Post New Thread
Results 1 to 15 of 15
How do you do....it? Thread, Sysprep & Renaming Computers in Technical; I've got a new Sysprepped image of XP that does all the business (single image for all hardware etc), fully ...
  1. #1

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    242

    Sysprep & Renaming Computers

    I've got a new Sysprepped image of XP that does all the business (single image for all hardware etc), fully automated up until logon etc etc.

    But at the moment, it gets to log on and I have two 'problems'. I say 'problems' because it's not major, but would be nice to be completely automated so hence it's a 'problem'.

    1) Is there a way to do the renaming of machines automatically. At the moment my sysprep.inf has a '*' in it meaning it's given a random name. Is there any way to either:

    a) Have it login, and provide a renaming script so ICT1-001 or whatever can be quickly entered?
    b) Pick up on a MAC address or something and automatically 'know' what each computer needs to be called?

    2) Is there a way to automatically transfer the computers into the right OU in AD so they pick up the appropriate GPO's? I know this is a simple case of dragging/dropping/restarting but automation is gooooooood!

  2. #2
    simpsonj's Avatar
    Join Date
    Apr 2009
    Location
    Oxford
    Posts
    414
    Thank Post
    168
    Thanked 71 Times in 60 Posts
    Blog Entries
    8
    Rep Power
    23
    Is this using WDS at all? If so, in Windows Deployment Services on the server, right click server name, choose properties, then the AD DS tab and you can choose a naming convention and where in the Active Directory you want new PCs to be placed.

  3. #3

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    242
    Quote Originally Posted by simpsonj View Post
    Is this using WDS at all? If so, in Windows Deployment Services on the server, right click server name, choose properties, then the AD DS tab and you can choose a naming convention and where in the Active Directory you want new PCs to be placed.
    That does it for all generally. But I'm talking more of a how do I put ICT1 PC's into ICT1 OU etc etc

  4. #4
    simpsonj's Avatar
    Join Date
    Apr 2009
    Location
    Oxford
    Posts
    414
    Thank Post
    168
    Thanked 71 Times in 60 Posts
    Blog Entries
    8
    Rep Power
    23
    Personally I would just make the change before I built up the ICT suite, so if I knew I was going to rebuild Room 29, then I would make the changes in WDS and then rebuild that room.

    Otherwise I imagine its in the Unattend.xml, but that's beyond me I'm afraid.

  5. #5

    Join Date
    Oct 2007
    Location
    Northamptonshire
    Posts
    315
    Thank Post
    22
    Thanked 83 Times in 70 Posts
    Rep Power
    45
    You could use Fog to do this. I've been using it recently with a hardware independent XP image and it really does make OS deployment a breeze.

  6. #6
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,007
    Thank Post
    124
    Thanked 286 Times in 263 Posts
    Rep Power
    109
    Use a script using netdom and have it reference some kind of lookup file for mac to hostname lookup.

  7. #7

    Norphy's Avatar
    Join Date
    Jan 2006
    Location
    Harpenden
    Posts
    2,581
    Thank Post
    59
    Thanked 371 Times in 287 Posts
    Blog Entries
    7
    Rep Power
    134
    Quote Originally Posted by Hightower View Post
    That does it for all generally. But I'm talking more of a how do I put ICT1 PC's into ICT1 OU etc etc
    You pre-stage the PCs in AD.

    Take a note of the GUIDs (Globally Unique Identifiers) of the PCs (The long number that appears when you boot from PXE). If it isn't already there, install ADUC on the server that has WDS on it. Open ADUC and go to the OU where you want the PC installed. Create a new computer object and when prompted, check the "This is a managed computer" box. It will then ask you for the GUID of the computer.

    Assuming you got your sysprep.inf file correct, when you rebuild the PC with this image it will now automatically join your PC to the domain with the correct name and in the correct location.

    Admittedly, this is long winded and a pain but at least once it's done, it's done and won't have to be done again. You could probably automate the process too, the GUID is just another field inside the computer object's account in AD. With a bit of scripting you could extract the GUIDs from your computers and then create another script to pre-populate them for you.

  8. Thanks to Norphy from:

    Hightower (11th March 2011)

  9. #8

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    242
    Quote Originally Posted by Norphy View Post
    You pre-stage the PCs in AD.

    Take a note of the GUIDs (Globally Unique Identifiers) of the PCs (The long number that appears when you boot from PXE). If it isn't already there, install ADUC on the server that has WDS on it. Open ADUC and go to the OU where you want the PC installed. Create a new computer object and when prompted, check the "This is a managed computer" box. It will then ask you for the GUID of the computer.

    Assuming you got your sysprep.inf file correct, when you rebuild the PC with this image it will now automatically join your PC to the domain with the correct name and in the correct location.

    Admittedly, this is long winded and a pain but at least once it's done, it's done and won't have to be done again. You could probably automate the process too, the GUID is just another field inside the computer object's account in AD. With a bit of scripting you could extract the GUIDs from your computers and then create another script to pre-populate them for you.
    I think that sounds like the closest solution to what I was looking for. Thanks for this! Gonna have a play and see if I can extract them from our current AD structure and import the accounts ready for our new AD structure.

  10. #9

    Norphy's Avatar
    Join Date
    Jan 2006
    Location
    Harpenden
    Posts
    2,581
    Thank Post
    59
    Thanked 371 Times in 287 Posts
    Blog Entries
    7
    Rep Power
    134
    You'll only be able to extract the GUIDs from AD if you built your PCs using RIS/WDS previously. Now that I'm at work, I can look at ADSI Edit and look up the field that needs to be filled in, it's called netbootGUID so check your computer accounts and see if its there or not.

    If it isn't, you should be able to extract it using a WMI query. I *think* the field that you're looking for is called UUID in the SystemProduct table so a query like "select UUID from SystemProduct" under the root\CIMv2 namespace should return it. Or you can use something like Lansweeper to collect it all for you.

  11. #10

    sparkeh's Avatar
    Join Date
    May 2007
    Posts
    7,231
    Thank Post
    1,446
    Thanked 1,859 Times in 1,252 Posts
    Blog Entries
    22
    Rep Power
    559
    You can also enter the MAC address to prestage machines which is great for new machines.

  12. #11

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,159
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    125
    Bit late, but this might help. It assumes you've got a file or database of machine mac addresses, desired names and OUs and then moves the machine to the right OU and renames it.

    It makes use of netdom (and assumes it's on the path) and needs an account username and password in the script which can rename a computer. it also does a reboot at the end.

    Code:
    set oFSO=createobject("scripting.filesystemobject")
    set oFile=ofso.opentextfile("h:\vbscript\computers.csv")
    sData=oFile.readall
    oFile.close
    
    'find the mac address and current hostname - assumes using DHCP
    Set oWMI = GetObject("WinMGMTS:root\cimv2")
    sWQL = "SELECT DNSHostName,MacAddress FROM Win32_NetworkAdapterConfiguration where DHCPEnabled=true" 
     set colResults = oWMI.ExecQuery(sWQL)
     For Each oNIC In colResults
    	  sMac=oNIC.MACAddress 
    	  sHostname=oNic.DNSHostName
      Next
    
    'get the details for this MAC address from data file
    iDataStart=instr(1,sData,sMac,vbTextCompare) 'start searching from beginning and do case insensitive compare
    if iDataStart<>0 then 
    	'we've got a match
    	iDataEnd=instr(iDataStart,sData,vbcrlf) 'find the end of line
    	sInfo=mid(sData,iDataStart,iDataEnd-iDataStart)
    	sItems=split(sInfo,"|")
    	sNewName=sItems(1)
    	sOu=sItems(2)
    else
    	wscript.echo "Can't find this PC; ending"
    	wscript.quit
    end if
    
    'connect to AD
    Set oRootDSE = GetObject("LDAP://RootDSE")
    sDNSDomain = oRootDSE.Get("defaultNamingContext")
    Set ocommand = CreateObject("ADODB.Command")
    Set oConn = CreateObject("ADODB.Connection")
    oConn.Provider = "ADsDSOObject"
    oConn.Open "Active Directory Provider"
    ocommand.ActiveConnection = oConn
    
    'build up a command string
    sBase = "<LDAP://" & sDNSDomain & ">"
    sFilter="(&(objectCategory=computer)(cn=" & sHostName & "))"
    sAttributes = "distinguishedname"
    
    sQuery = sBase & ";" & sFilter & ";" & sAttributes & ";subtree"
    ocommand.CommandText = sQuery
    
    'and search AD
    Set oRS = ocommand.Execute
    if oRS.eof then
    	wscript.echo "Can't find this PC in active directory; ending"
    	wscript.quit
    else
    	sDN=ors(sAttributes).value
    end if
    
    'bind to the new OU
    Set ou=getobject("LDAP://" & sOU)
    'and move the PC
    ou.movehere "LDAP://" & sDN,vbNullString
    	
    'finally rename it
    sCmd="netdom /renamecomputer " & sHostname & " /newname:" & sNewName & " /userd:domain\username /passwordd:ReallyS3cr3tPassword! /force /reboot:10"
    oShell.run sCmd

  13. Thanks to srochford from:

    Churchers (27th April 2011)

  14. #12

    Join Date
    Sep 2010
    Location
    Hampshire
    Posts
    12
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Please can you let me know how the CSV should be structured.
    Thanks

  15. #13

    Join Date
    Sep 2010
    Location
    Hampshire
    Posts
    12
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    OK worked out csv file:

    00:00:00:00:00:00|PC001|Computers
    00:00:00:00:00:00|PC002|Computers
    (REMEMBER: the last record needs a return on the end as it's used in the script)
    ...|"Computers" might not be correct as i'm not using AD section of script so have not tested. might need dn=example dn=com etc....


    Although I have disabled the AD section in the script, (1) I don't understand this section (2) It didn't work out the box (3) it's not used in the netdom string...
    Can you please translate section...

    Currently error's at line 30 < Set oRootDSE = GetObject("LDAP://RootDSE") >
    Last edited by Churchers; 27th April 2011 at 01:03 AM.

  16. #14

    Join Date
    Apr 2011
    Location
    Pennsylvania
    Posts
    48
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    8
    Quote Originally Posted by Ashm View Post
    You could use Fog to do this. I've been using it recently with a hardware independent XP image and it really does make OS deployment a breeze.
    Agreed. I went to a WDS conference and it crashed during their presentation... I ended up staying with FOG and began using the FOG Service for renaming computers on the fly. It's proving to be extremely, extremely handy.

  17. #15

    Join Date
    Sep 2010
    Location
    Hampshire
    Posts
    12
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Yep, we also went with FOG



SHARE:
+ Post New Thread

Similar Threads

  1. [MDT] Sysprep & Imaging
    By Chuckster in forum O/S Deployment
    Replies: 1
    Last Post: 10th February 2011, 11:22 PM
  2. sysprep & media player 11
    By ICT_GUY in forum Windows
    Replies: 7
    Last Post: 15th May 2009, 09:55 AM
  3. Sysprep & Drive Letters
    By jack0w in forum Windows
    Replies: 26
    Last Post: 16th September 2008, 08:24 PM
  4. Vista SP1, Sysprep & UserLock...
    By Gatt in forum Windows Vista
    Replies: 2
    Last Post: 7th March 2008, 02:25 PM
  5. Sysprep & Ghost
    By cgiuk in forum How do you do....it?
    Replies: 13
    Last Post: 26th November 2007, 10:14 AM

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
  •