Jump to content

Recommended Posts

Posted

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! :)

Posted
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.
Posted
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

Posted

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.

Posted
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.
Posted
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.

  • Thanks 1
Posted
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.

Posted

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.

Posted

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.

 


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 = ""
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

  • Thanks 1
  • 1 month later...
Posted (edited)

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") >

Edited by Churchers
Posted
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.

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...