Specify Computer Name for OSD
In SMS 2003, we could specifya computer name before the image ran, and the comptuer did not have to be added to a collection ahead of time. I am able to get by the second part, using the PXEFilter.vbs that comes with the Micorsoft Deployment Kit, but it adds the comptuer to the collection with a name "MAC00112233445566" and once the image runs, that the computer name that it takes on. Is there a way to change that in the filter? Or have some sort of prompt that allows me to choose the computer name? Thanks!
April 15th, 2008 1:49am

Hey ya, In SCCM you can add a Task in the task sequence to run a VB script, this can be something like the following; dim envstrNewName = "wrongname" Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & "." & "\root\cimv2") Set colSMBIOS = objWMIService.ExecQuery _ ("Select * from Win32_SystemEnclosure") For Each objSMBIOS in colSMBIOS strNewName = objSMBIOS.SerialNumber Next SET env = CreateObject("Microsoft.SMS.TSEnvironment") env("OSDCOMPUTERNAME") = "CCA-"&strNewName This will be to be adjusted to suite your enviroenment, but it does the job. This script acrually runs a WMI query and searches for the devices serial number, and actually names thecomputer this. Let me know if this is what you were after. Cheers,
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2008 7:52am

The easiest way to name the machines is via the database.
April 15th, 2008 2:59pm

Does this script prompt for a computer name? We never name the machines their serial number or MAC, we have a numbering system instead. The helpdesk technicians do not have access to all of Config Mgr, and I need them to be able to name the machines as they need to.
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2008 7:39pm

Check out this post: http://myitforum.com/cs2/blogs/jmarcum/archive/2008/04/11/114875.aspx
April 15th, 2008 9:08pm

I haven't tested this in a SCCM OSD, butI do know you can also create a VB Script that can prompt you to add a computer name, now in theary if you add a task in the same spot that the one mentioned earlier is then in theory this should work, The script I have used in a BDD & MDT light touch envioenment is as follows; Option Explicit Dim numCountDim strComputerNameDim objOSD Do While numCount = 0 strComputerName = InputBox ("Please enter a name for the new computer:","New Computer Name","Vista00",10,10) If strComputerName = "" Then Wscript.Echo "You must enter a computer name." ElseSet objOSD = CreateObject("OSD.Environment")objOSD("OSDNEWMACHINENAME") = strComputerNameSet objOSD = Nothing Exit Do End IfLoop This is also something that was picked up on a previous thread and was changedd and made a .wsf file. <job id="ZTIPromptForComputerName"> <script language="VBScript" src="ZTIUtility.vbs"/> <script language="VBScript">Option Explicit Dim numCountDim strComputerNameDim objOSD Do While numCount = 0 strComputerName = InputBox ("Please enter a name for the new computer:","New Computer Name","",10,10) If strComputerName = "" Then Wscript.Echo "You must enter a computer name." Else oEnvironment.Item("OSDNEWMACHINENAME") = strComputerName oEnvironment.Item("OSDCOMPUTERNAME") = strComputerName Exit Do End IfLoop </script> </job> Is this of any further help. Cheers, Josh
Free Windows Admin Tool Kit Click here and download it now
April 16th, 2008 2:51am

This is probably a dumb question but since there's a method built into Lite Touch to prmpt for a computer name why would you write a script to do that?? Which brings me to my second question, if you are going to prompt for information during a zero touch deployment then it is no longer "zero" touch so what's the point? Johan and Jason Scheffelmaer both wrote front ends for BDD 2007 which would allow you to prompt for stuff during ZTI andmaybe those can be ported over to MDT. I know Johan saidhis won't work as is, but maybe you could make it work?But again I think you shouldn't prompt for info during a zero touch deployment so use the database and you don't have too.
April 16th, 2008 4:08am

Correct, unless there is some sort of unified naming convension that you can tie into the script then this will no longer be a Zero Touch Installation. The problem with SCCM is to date I've not been able to find a way to have the MDT database control the OSD install via SCCM I know if SMS 2003 this is very much achievable. Cheers,
Free Windows Admin Tool Kit Click here and download it now
April 16th, 2008 4:26am

I'd also like to also mention that SCCM SP2 or R2 will have much more enhanced features around bare metal builds that will also take into account this. Just an FYI.
April 16th, 2008 4:32am

You simply specify the SQLServer=ServerName, Database=DatabaseName etc in your cs.ini. Here's what my cs.ini looks like. Then you can use the web based front end I showed you in my blog to allow your help desk people enter the computer name, roles and any other settings you want them to enter prior to deplyoing the image. Also if you have problems connecting to the database here's some troubleshooting tips: http://technet.microsoft.com/en-us/library/bb978382.aspx?wt.svl=highlights [Settings]Priority=CPackages, CApps, CAdmins, CRoles, Locations, LSettings, LPackages, LApps, LAdmins, LRoles, MMSettings, MMPackages, MMApps, MMAdmins, MMRoles, RSettings, RPackages, RApps, RAdmins, CSettings, DefaultProperties=BackupDrive [Default]OSInstall=YUSMTMigFiles1=MigApp.xmlUSMTMigFiles2=MigUser.xmlUSMTMigFiles3=MigSys.xmlUSMTMigFiles4=MigNetworkPrinters.xmlScanStateArgs=/v:5 /o /c /ue:%COMPUTERNAME%\*LoadStateArgs=/v:5 /c /lacUserDataLocation=AUTOResourceRoot=\\%SMSDP%\Distribution$ComputerBackupLocation=AUTOBackupDrive=ALLBackupShare=\\%SMSDP%\MigDataBackupDir=%ComputerName%\BackupUDShare=\\%SMSDP%\MigDataUDDir=%ComputerName%\UserData [CSettings]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=ComputerSettingsParameters=UUID, AssetTag, SerialNumber, MacAddressParameterCondition=OR [CPackages]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=ComputerPackagesParameters=UUID, AssetTag, SerialNumber, MacAddressParameterCondition=OROrder=Sequence [CApps]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=ComputerApplicationsParameters=UUID, AssetTag, SerialNumber, MacAddressParameterCondition=OROrder=Sequence [CAdmins]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=ComputerAdministratorsParameters=UUID, AssetTag, SerialNumber, MacAddressParameterCondition=OR [CRoles]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=ComputerRolesParameters=UUID, AssetTag, SerialNumber, MacAddressParameterCondition=OR [Locations]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=LocationsParameters=DefaultGateway [LSettings]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=LocationSettingsParameters=DefaultGateway [LPackages]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=LocationPackagesParameters=DefaultGatewayOrder=Sequence [LApps]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=LocationApplicationsParameters=DefaultGatewayOrder=Sequence [LAdmins]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=LocationAdministratorsParameters=DefaultGateway [LRoles]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=LocationRolesParameters=DefaultGateway [MMSettings]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=MakeModelSettingsParameters=Make, Model [MMPackages]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=MakeModelPackagesParameters=Make, ModelOrder=Sequence [MMApps]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=MakeModelApplicationsParameters=Make, ModelOrder=Sequence [MMAdmins]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=MakeModelAdministratorsParameters=Make, Model [MMRoles]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=MakeModelRolesParameters=Make, Model [RSettings]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=RoleSettingsParameters=Role [RPackages]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=RolePackagesParameters=RoleOrder=Sequence [RApps]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=RoleApplicationsParameters=RoleOrder=Sequence [RAdmins]SQLServer=server.domain.comDatabase=AdminDBNetlib=DBNMPNTWSQLShare=E$Table=RoleAdministratorsParameters=Role
Free Windows Admin Tool Kit Click here and download it now
April 16th, 2008 3:17pm

Josh, when I add the task with your .vbs script it prompts me for a computer name, but doesnt change anything. The computer still stays named MAC00112233445566, or the previous computer name that it was.
April 16th, 2008 9:23pm

ok, well as I said I've never actually put this into practice so not sure how it will work. Have you tried the .wsf script as well?
Free Windows Admin Tool Kit Click here and download it now
April 16th, 2008 11:47pm

The .wsf script throws and error in the task sequence.
April 17th, 2008 2:24am

Is there any "Best Practice" way to name computers with OSD? There are several ways i can see to set the name of a computer if it is based on a system variable like serial number: 1) In the Admin Database the Computer, Location, Make or Model and Role databases could have a computer named defined for each computer 2) The CustomSettings.ini could have the "ComputerName=" option set for all computers 3) The ComputerNamevariable could be set in the Task Sequence 4) A script could be used to set the environment variable during the task sequence. What is the "Best Practice" place for setting the computer name? (Assuming it is based on a variable that is available at build time. ie. PC-%ASSETTAG% or Laptop-%SerialNumber%)
Free Windows Admin Tool Kit Click here and download it now
April 17th, 2008 8:50am

There's no "Microsoft" best practice as it's usually a business driven decision. Although, the organisations I've implemented these sorts of solutions for have often gone down the serial number/asset tag track mainly for asset tracking. It provides the helpdesk aneasy for managing calls particularly with hardware faults and so on. Any help? Cheers,
April 17th, 2008 10:28am

I agree. Sticking to a naming convention that can be tracked to a specific piece of hardware without the use of an intermediate CMDB is certainly the best way to do it. I guess what I am really after is the best place in SCCM OSD to set this for all machines. Having to enter the computer name format in each of the Admin DB enteries for each computer seems to be a lot of repetition for no benefit. Is it better to place this directly in the CustomSettings.ini? Or Is the task sequence the best place for this setting? -- Moff
Free Windows Admin Tool Kit Click here and download it now
April 18th, 2008 1:38am

I haven't read all articles so someone may have said the same thing before me. But I had the same problem with computer names. My solution was: Configure WDS to only answare to know computers. Change the pxefilter.vbs script to open AD and find the computername from AD based on the Netbootguid in AD and the UUID from PXE.UUID. If someone tries to installOS on an computers without adding it to AD it won't work. Or if they type in work GUID it won't work. However, if a computer is known in SCCM 2007 but not in AD it will work to install the OS. Hope this was at any use at all. Geir G
August 20th, 2008 5:00pm

Hi thereCan someone please explain in a step by step for perhaps as to how to get this working. I have read countless articles and tried everyones scripts here in my task sequence, all of them fail. I dont even get prompted for a computer name. where in the task sequence should the script be added and what should the exact command be?I dont use MDT at the moment because everything else is working as i want it, just not this rename computer name.any help will be greatly appreciated.Phil
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2008 6:38pm

I think it is to late to ask for computer name in the task sequence. When you boot on PXE the PXEFilter checks the collection to se if there is an computer with the same GUID og MAC address. If ther isn't it creates on System Object with a given name. I use Active Directory and the GUID to find the name. Since the PXEfilter is running on the WDS server there is no way to get a prompt up on the client computer. I have made one solution where there is a prompt for computer name on the clinet, but I don't use PXE from SCCM, I have created a boot.wim file for SCCM wich is added into the standard WDS services. What is your goal? Is a prompt on the client computer the only option? Or is it possible to add the computer object i AD befor installing the OS, and get the name from AD? Geir G
September 17th, 2008 6:49pm

Ideal situation would be for a promt to come up somewhere during the process, my desktop support team must be able to enter a computer name as we adhere to strict naming conventions. This should preferably be done before the computer joins the domain...if possible,
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2008 7:58pm

Hmmm. This is gone take some time. I will describe how I did this. First you must remove the PXE komponent from the WDS server. Then you create a task sequence media for boot only. Extract the ISO file. Mount the BOOT.WIM file with the IMAGEX tool. comes with WAIK. Copy the SMS\DATA directory into the SMS directory in the BOOT.WIM you have mounted. Change the file windows\system32\winpeshl.ini in the BOOT.WIM to start START.BAT instead of the TsBootShell.exe Create a START.BAT file which start initnet.vbs, Offline.vbs and TsBootShell.exe initnet.vbs look something like this: This script is based on the PXEFilter.vbs from Microsoft. I added support for AD lookup. _____________________________________________________________________________________ set wshell = CreateObject("WScript.Shell")wscript.echo "starting wpeinit.exe"wshell.run "wpeinit.exe",0,trueSet objWMIService = GetObject( "winmgmts:\\.\root\CIMV2") wscript.sleep(1000)wscript.echo "Waiting for wpeinit do end."doiTeller = 0Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = ""wpeinit.exe""",,48) for each Proc in colItems iTeller = iTeller + 1nextwscript.sleep(5000)wscript.echo "."set colItems=nothingloop until iTeller = 0 Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration",,48) sIPAdresse = ""For Each objItem in colItems wscript.echo "Caption: " & objItem.CaptionsMacAddress = objItem.MACAddresssIPAddress = objItem.IPAddress(0)if sIPAdresse <> "" thenexit forend ifNext______________________________________________________________________________________ The Offline.vbs look something like this: ______________________________________________________________________________________ Dim sProviderServerDim sSiteCodeDim sNamespaceDim sUsernameDim sPasswordDim sCollectionDim DomainNamedim UseDomainName sProviderServer = "vdsms01.veidekke-no.veidekke.net"sSiteCode = "VDE"sNamespace = "root\sms\site_" & sSiteCodesUsername = ""sPassword = ""sCollection = "SMS0000A" ' This must be a collection ID, not a collection nameDomainName = ""strComputer = "." UseDomain = false'//----------------------------------------------------------------------------'// Main routine'//---------------------------------------------------------------------------- ZTIProcess Function ZTIProcess Dim sMacAddressDim sIPAddressDim sUUIDDim sNetBiosNameDim oLocatorDim oSMSDim sQueryDim bFoundDim iResourceIDDim reDim oSiteDim oParamsDim oResultDim oLastErrorDim oClientsDim oClientDim oCollectionDim oNewRuleDim oAdvertisementDim bTryingDim sAdvertDim i ' Initializationwscript.echo "Getting information from OS"Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colItems = objWMIService.ExecQuery( "SELECT * FROM Win32_NetworkAdapterConfiguration",,48) sIPAdresse = ""For Each objItem in colItems wscript.echo "Caption: " & objItem.Caption'wscript.echo "DHCPEnabled: " & objItem.DHCPEnabledsMacAddress = objItem.MACAddresssIPAddress = objItem.IPAddress(0)if sIPAdresse <> "" thenexit forend ifNext Set SystemSet = GetObject("winmgmts:").InstancesOf ("Win32_ComputerSystemProduct")For Each SystemItem In SystemSet szUUID = SystemItem.UUID sUUID = szUUIDNextSet re = New RegExpre.Pattern = ":"re.Global = true'sNetBiosName = "MAC" & re.Replace(sMacAddress, "")wscript.echo "Clear invalid UUID values" If sUUID = "00000000-0000-0000-0000-000000000000" or sUUID = "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF" thensUUID = ""End if ' Log details wscript.echo "Processing request from MAC address = " & sMacAddress & ", IP address = " & sIPAddress & ", UUID = " & sUUID '//----------------------------------------------------------------------------'// Filter requests. This may need to be customized if you only want some'// network segments to be supported.'//---------------------------------------------------------------------------- ' Ignore ConfigMgr "ping" requests '//----------------------------------------------------------------------------'// Verify the computer is known to ConfigMgr'//---------------------------------------------------------------------------- wscript.echo "Connect to the SMS provider" Set oLocator = CreateObject("WbemScripting.SWbemLocator")set oSMS = nothingTryCount = 0on error resume nextdoSet oSMS = oLocator.ConnectServer(sProviderServer, sNamespace, sUsername, sPassword)if err.number <> 0 thenwscript.echo err.descriptionend ifwscript.echo "."loop until typename(oSMS)<>"Nothing"on error goto 0 wscript.echo typename(oSMS)wscript.echo "Build the query" sQuery = "SELECT * FROM SMS_R_System WHERE MacAddresses = '" & sMacAddress & "'"If sUUID <> "" thensQuery = sQuery & " OR SMBIOSGUID = '" & sUUID & "'"End if wscript.echo "Process the query" bFound = FalseSet oClients = oSMS.ExecQuery(sQuery)For each oClient in oClientsbFound = trueiResourceID = oClient.ResourceIDwscript.echo "Found existing machine " & oClient.NetbiosName & " with ResourceID = " & iResourceIDsNetBiosName = oClient.NetbiosNameExit ForNext '//----------------------------------------------------------------------------'// If necessary, add the computer to the ConfigMgr database'//---------------------------------------------------------------------------- If not bFound then wscript.echo "Could not find machine with MAC address '" & sMacAddress & "' or SMBIOS UUID '" & sUUID & "'."if UseDomain thensNetBiosName = GetComputerName(sUUID,DomainName,sUsername,sPassword)wscript.echo "Got computername from AD: " & sNetBiosNameelsesNetBiosName = inputbox("PC ikke funnet i System Center, skriv inn nsket PC navn.","PC Navn")wscript.echo "Hentet navn fra bruker: " & sNetBiosNameend if ' Add the computer Set oSite = oSMS.Get("SMS_Site")Set oParams = oSite.Methods_.Item("ImportMachineEntry").inParameters.SpawnInstance_()oParams.NetbiosName = sNetBiosNameoParams.SMBIOSGUID = sUUIDoParams.MACAddress = sMacAddressoParams.OverwriteExistingRecord = false On Error Resume NextSet oResult = oSite.ExecMethod_("ImportMachineEntry", oParams)If Err thenwscript.echo "Error importing machine entry: " & Err.Description & " (" & Err.Number & ")"Set oLastError = CreateObject("WbemScripting.SWbemLastError")wscript.echo "Last WMI error: " & oLastError.DescriptionExit FunctionEnd ifOn Error Goto 0 iResourceID = oResult.ResourceIDwscript.echo "Added new machine with ResourceID = " & iResourceID End if '//----------------------------------------------------------------------------'// Check if the computer is a member of the specified collection'//---------------------------------------------------------------------------- If bFound thenwscript.echo "Computer Found"' Build the query sQuery = "SELECT * FROM SMS_CM_RES_COLL_" & sCollection & " WHERE ResourceID = " & iResourceId wscript.echo "Process the query"wscript.echo sQuerybFound = Falseset oClients = nothingSet oClients = oSMS.ExecQuery(sQuery)wscript.echo "Sjekker resultat"if isobject(oClients) thenwscript.echo "object OK"elsewscript.echo "object NOTOK"end ifwscript.echo typeName(oClients) on error resume nextFor each oClient in oClientsbFound = truewscript.echo "Machine is already in collection " & sCollectionExit ForNextwscript.echo "Resultat sjekket"on error goto 0End if wscript.echo "bFound: " & bFound '//----------------------------------------------------------------------------'// If necessary, add the computer to the specified collection'//---------------------------------------------------------------------------- If not bFound thenwscript.echo "Computer not found"' Add the computer to the specified collection On Error Resume NextSet oCollection = oSMS.Get("SMS_Collection.CollectionID='" & sCollection & "'")If Err thenwscript.echo "Error retrieving collection " & sCollection & ": " & Err.Description & " (" & Err.Number & ")"Set oLastError = CreateObject("WbemScripting.SWbemLastError")wscript.echo "Last WMI error: " & oLastError.DescriptionExit FunctionEnd ifOn Error Goto 0 Set oNewRule = oSMS.Get("SMS_CollectionRuleDirect").SpawnInstance_()oNewRule.ResourceClassName = "SMS_R_System"oNewRule.RuleName = sNetBiosNameoNewRule.ResourceID = iResourceID On Error Resume NextoCollection.AddMembershipRule oNewRuleIf Err thenwscript.echo "Error adding membership rule to " & sCollection & ": " & Err.Description & " (" & Err.Number & ")"Set oLastError = CreateObject("WbemScripting.SWbemLastError")wscript.echo "Last WMI error: " & oLastError.DescriptionExit FunctionEnd ifOn Error Goto 0wscript.echo "Added new membership rule to collection " & sCollection End if '//----------------------------------------------------------------------------'// Wait until an advertisement is seen.'//---------------------------------------------------------------------------- ' Check for the advertisements Set oAdvertisement = oSMS.Get("SMS_Advertisement")i = 0bTrying = TrueDo While bTrying Set oParams = oAdvertisement.Methods_("GetAdvertisements").inParameters.SpawnInstance_()oParams.ResourceID = iResourceID Set oResult = oAdvertisement.ExecMethod_("GetAdvertisements", oParams)For each sAdvert in oResult.AdvertisementIDswscript.echo "Found advertisement " & sAdvertbTrying = FalseNextwscript.echo "."i = i + 1If bTrying and i > 10 thenwscript.echo "Giving up after 30 seconds of checking for new advertisements."bTrying = FalseEnd ifif bTrying thenwscript.sleep 5000end ifLoop wscript.echo "Exiting PXEFilter.vbs" End Functionfunction GetComputerName(sGUIDin,sDomain,sUserName,sPassword)dim condim ocommanddim sADsPathdim sGUIDmoddim iTellerdim sFilterdim sAttribsToReturndim sDepthdim rsdim Navndim domaindim sGUIDdim sTempGetComputerName = ""Set Con = CreateObject("ADODB.Connection")Con.Provider = "ADsDSOObject"if sUserName <> "" thenCon.Properties("User ID")=sUserNameCon.properties("Password") = sPasswordCon.properties("Encrypt password")=trueend ifCon.Open "Active Directory Provider"Set ocommand = CreateObject("ADODB.Command")ocommand.ActiveConnection = ConsADsPath = sDomain'sGUIDmod = PackGUID(sGUIDin)sGUIDmod=sGUIDinsGUIDmod=replace(sGUIDmod,"-","")sGUIDmod=replace(sGUIDmod,"{","")sGUIDmod=replace(sGUIDmod,"}","")sTEmp = sGUIDmodsGUIDmod = ""for iTeller = 1 to 32 step 2sGUIDmod = sGUIDmod & "\" & mid(sTemp,iTeller,2) nextsTemp = PackGUID(sGUIDin)sGUID = ""for iTeller = 1 to 32 step 2sGUID = sGUID & "\" & mid(sTemp,iTeller,2) nextsFilter = "(&(objectCategory=computer)(objectClass=computer)(netbootGUID=" & sGUIDmod & "))"'sFilter = "(&(objectCategory=computer)(objectClass=computer)(netbootGUID=\56*))"sAttribsToReturn = "name,netbootGUID,distinguishedName" sDepth = "subTree" ocommand.CommandText = sADsPath & ";" & sFilter & ";" & sAttribsToReturn & ";" & sDepth Set rs = ocommand.ExecuteIf rs.RecordCount > 0 Thenrs.MoveFirst While Not rs.EOFNavn = rs("Name")GetComputerName = Navnrs.MoveNextWendset rs = NothingelsesFilter = "(&(objectCategory=computer)(objectClass=computer)(netbootGUID=" & sGUID & "))"sAttribsToReturn = "name,netbootGUID,distinguishedName"sDepth = "subTree"ocommand.CommandText = sADsPath & ";" & sFilter & ";" & sAttribsToReturn & ";" & sDepthSet rs = ocommand.Executeif rs.RecordCount > 0 thenNavn = rs("Name")GetComputerName = Navnrs.MoveNextend ifSet rs = Nothing End If set domain = nothingset ocommand = nothingset con = nothingend function '*******************************************************************************'*******************************************************************************' To convert a GUID like {E09B48B5-E141-427A-AB0C-D3605127224A} to' the packed (commonly used in the registry) format like' 5B84B90E141EA724BAC03D06157222A4Function PackGUID(guid)PackGUID = "" ' Remove brackets if they existDim temptemp = Replace( guid, "{", "")temp = Replace( temp, "}", "") ' split the guid on the hyphenDim partpart = Split(temp,"-") ' build the packed version of the guidDim packpack = ""Dim i, j' reversing the sequence of the first 3 parts from the leftFor i = 0 To 2 'UBound(part)For j = Len(part(i))-1 To 1 Step -2pack = pack & Mid(part(i),j,2)NextNextFor i = 3 To 4For j = 1 to Len(part(i)) Step 2pack = pack & Mid(part(i),j,2)NextNext PackGUID = packEnd Function '*******************************************************************************'*******************************************************************************' Function to convert OctetString (byte array) to Hex string.' Code from Richard Mueller, a MS MVP in Scripting and ADSIFunction ConvertOctetToHexStr (arrbytOctet)Dim k ConvertOctetToHexStr = "" For k = 1 To Lenb (arrbytOctet)ConvertOctetToHexStr = ConvertOctetToHexStr & Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)NextEnd Function ' Function to convert OctetString (byte array) to Hex string.' Code from Richard Mueller, a MS MVP in Scripting and ADSIFunction ConvertOctetToHexStr (arrbytOctet)Dim k ConvertOctetToHexStr = "" For k = 1 To Lenb (arrbytOctet)ConvertOctetToHexStr = ConvertOctetToHexStr & Right("0" & Hex(Ascb(Midb(arrbytOctet, k, 1))), 2)NextEnd Function '*******************************************************************************'*******************************************************************************' Converts an array of Bytes to a "\" separated stringFunction myADsEncodeBinaryData (arrByte)Dim str, s, i'WScript.Echo "" str = ConvertOctetToHexStr (arrByte)'WScript.Echo "Length = " & len(str) & " '" & str & "'" s = ""For i = 1 to Len (str) Step 2s = s & "\" & Mid (str, i, 2)Next'WScript.Echo s myADsEncodeBinaryData = sEnd Function___________________________________________________________________________________________________ Commit the changes done on the BOOT.WIM file. Add the BOOT.WIM file into your WDS server as a boot image. Give it a reasonable name like "SCCM OSD"? Now you should be able to boot with PXE from the WDS server and choose "SCCM OSD" from there. When you boot from this file everything is done on the client and you are able to give a prompt for name. Remember to insert username and password in the offline.vbs file <domain>\<username> syntax. Hopes this is helpfull for you. I used some time before I managed to do this the first time. Of course I hade to make the VBS script at the same time. Geir G
September 17th, 2008 9:07pm

HI GeirThank you VERY MUCH for your detailed explination. I couple of things about my environment, I use the R2 version which comes with unknown computer support which works GREAT and I see your answer has alot to do with recognizing the computer and adding it to a collection. I also dont use the PXEFilter. I also dont have any boot images configured in WDS as SCCM takes care of that. I will howerver give your suggestion a go tomorrow when I am back at work, creating a new boot image, and using that. Could you please give me an example of what the start.bat should look like?ThanksPhil
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2008 9:40pm

Start.bat is simple: cscript initnet.vbscscript offline.vbs%SYSTEMDRIVE%\sms\bin\i386\TsBootShell.exe Do you mean SP1 or R2? I don't think I have got my ands on a R2 release yet. Geir g
September 17th, 2008 10:10pm

Hi GeirOk im actually doing this now, where should i put the following files START.BAT, initnet.vbs, Offline.vbs before i commit them to my boot.wim?Also in windows\system32 of my boot.wim?regardsPhil
Free Windows Admin Tool Kit Click here and download it now
September 17th, 2008 10:31pm

All files goes into the windows\system32 directory. Only the DATA directory should be under the SMS directory. If you have support for unknown computers it would be really nice to have this done in the task sequence. I have installer R2 on my lab server and I think I may have a solution for you. just have to test it first. Geir G
September 18th, 2008 10:54am

fantastic, im playing around now with running a rename script at the end of my TS, just need to find one that works, let me know how it goes on your side.
Free Windows Admin Tool Kit Click here and download it now
September 18th, 2008 11:11am

Think I have found a solution for this problem now. Running the last test. I am using "Operation System Install Package" and not "Operation System Images". I alson uses sysprep with unattend file. Not sure if this make any differense, but now you know my settings. I let you know as soon I have finished the last test. Geir G
September 18th, 2008 3:36pm

Then I have made a solution for asking the user for computername and setting this befor OS installation. It was simple to do actually. I just created a VBS script that run after the Partition disk step in the task sequence. The script is stored in a package which the task sequence download befor staring the script. The script just ask the user for computername and sett this value in the TaskSequence variable used to set computername during install. Just tested it and it worked just fine. Geir G
Free Windows Admin Tool Kit Click here and download it now
September 18th, 2008 4:01pm

Hi GeirThats fantastic, could you possibly discribe your steps and please provide me with the script. I have also got a script to change the computer name but im running it as part of a sysprep.inf, havent quite got it working so im keen to hear how you got it working.The task you use to call the package with your script in, is it a install software task?let me knowPhil
September 18th, 2008 4:15pm

Forgot to a the script. It's simple. I haven't put any finish into it. You should add some code to it so it got some finish. It show the current computername in a inputbox and lets you change it. When you change it, it is stored into the tasksequence varialbe which is used in the sysprep package. Belive it or not, this is the whole script: set env = CreateObject("Microsoft.SMS.TSEnvironment") sNetBiosName = inputbox("Type in the computernaem for this computer" ,_ "Computer name:",env("_SMSTSMachineName"),400,0) env("OSDComputerName") = sNetBiosName In the tasksequence I added an "run command line" and select the package that contains this script. Just typed in the name on the script. OBS: I have not tested this on "unkown system" yet. Running that test know. This is much easyer then the other metod I descibed befor. Hope this is helpfull for you. Please let me know how this work on WIM based installations. Geir G
Free Windows Admin Tool Kit Click here and download it now
September 18th, 2008 4:27pm

unfortunately im not too good at scripting, and that script doesnt work it fails. what is your full command line to call the script? and how would the full script look?
September 18th, 2008 4:54pm

Start: __________________________________________________________________ set env = CreateObject("Microsoft.SMS.TSEnvironment") Name = inputbox("Name1" ,"Name2:",env("_SMSTSMachineName"),400,0) env("OSDComputerName") = Name __________________________________________________________________ End. This is the whole script. I have done some small changes in it so it don't get cut off in this viewer. One line was changed during posting into this forum. Same script but shorter text in the textbox. You can change it later. I call the script GETCOMPUTERNAME.VBS and have created an packege whitout any programs and only this file. In the task sequence I run an command line. It is GETCOMPUTERNAME.VBS I select the package inthis step. This should work, If not post the errormessage. Geir G
Free Windows Admin Tool Kit Click here and download it now
September 18th, 2008 7:44pm

I had similar requirement and this script works.......Thanks a lot Praveen
September 20th, 2008 6:54pm

Hi Geir Thank you very much, it works 100%. Sorry for the late reply, things have been a bit hectic. cheers Phil
Free Windows Admin Tool Kit Click here and download it now
September 23rd, 2008 9:31am

You can create a computer association and import a single computer and add a hostname there. If you add computers using a .csv file you can add muliple systems at once. I know the pxe filter is nice but then you need a command line utility or vbscript to change the hostname before adding it to sccm.
September 23rd, 2008 1:30pm

Here's what I've done in my deployments. Not sure it is a great solution and recently I've stopped using this approach in favor of using the computer association in SCCM. WSF file (not vbs). Code Snippet <job id="ZTIPromptForComputerName"> <script language="VBScript" src="ZTIUtility.vbs"/> <script language="VBScript">Option Explicit Dim numCountDim strComputerNameDim objOSDdim laptopdim desktopdim oTypedim mnamedim SN laptop = oEnvironment.Item("IsLaptop")desktop = oEnvironment.Item("IsDesktop")SN = oEnvironment.Item("SerialNumber") if laptop = "True" ThenoType = "L"end ifif desktop = "True" ThenoType = "D"end ifwscript.echo SN mname = "??-" & oType & "-" & SN Do While numCount = 0 wscript.echo mname strComputerName = InputBox ("Please enter a name for the new computer:","New Computer Name",mname,10,10) If strComputerName = "" Then Wscript.Echo "You must enter a computer name." Else oEnvironment.Item("OSDNEWMACHINENAME") = strComputerName oEnvironment.Item("OSDCOMPUTERNAME") = strComputerName Exit Do End IfLoop </script> </job> I put a gather step just before this in the "new computer" section so that the information is gathered about the properties it is using and this sets it nicely from what I've seen. The above is more of a combination of what posts I've seen on the internet and adding my own stuff in there to detect laptop/desktop so I can use that value in naming along with SN for Dell Service tag (as an example). Also light touch does do this yes with a BDD GUI type thing but this also works for quick and dirty computer name prompting. Again if you add it in the computer association, it will keep that name thru the build process. If you have two different people / groups 1) building your machines2) adding into computer association area then a prompting script may make sense. I myself have decided to quit using it. Light touch use the wizard, SCCM / MDT OSD use the computer assoication and name it what you want to begin with. R2 gives the option for uknown computer support but also requires PXE which is another discussion (especially if port fast isn't in your environment). Jim
Free Windows Admin Tool Kit Click here and download it now
September 24th, 2008 5:09am

Here's what I've done in my deployments. Not sure it is a great solution and recently I've stopped using this approach in favor of using the computer association in SCCM. WSF file (not vbs). Code Snippet <job id="ZTIPromptForComputerName"> <script language="VBScript" src="ZTIUtility.vbs"/> <script language="VBScript">Option Explicit Dim numCountDim strComputerNameDim objOSDdim laptopdim desktopdim oTypedim mnamedim SN laptop = oEnvironment.Item("IsLaptop")desktop = oEnvironment.Item("IsDesktop")SN = oEnvironment.Item("SerialNumber") if laptop = "True" ThenoType = "L"end ifif desktop = "True" ThenoType = "D"end ifwscript.echo SN mname = "??-" & oType & "-" & SN Do While numCount = 0 wscript.echo mname strComputerName = InputBox ("Please enter a name for the new computer:","New Computer Name",mname,10,10) If strComputerName = "" Then Wscript.Echo "You must enter a computer name." Else oEnvironment.Item("OSDNEWMACHINENAME") = strComputerName oEnvironment.Item("OSDCOMPUTERNAME") = strComputerName Exit Do End IfLoop </script> </job> I put a gather step just before this in the "new computer" section so that the information is gathered about the properties it is using and this sets it nicely from what I've seen. The above is more of a combination of what posts I've seen on the internet and adding my own stuff in there to detect laptop/desktop so I can use that value in naming along with SN for Dell Service tag (as an example). Also light touch does do this yes with a BDD GUI type thing but this also works for quick and dirty computer name prompting. Again if you add it in the computer association, it will keep that name thru the build process. If you have two different people / groups 1) building your machines2) adding into computer association area then a prompting script may make sense. I myself have decided to quit using it. Light touch use the wizard, SCCM / MDT OSD use the computer assoication and name it what you want to begin with. R2 gives the option for uknown computer support but also requires PXE which is another discussion (especially if port fast isn't in your environment). Jim
September 24th, 2008 5:09am

I need to add script to SCCM OSD (not using MDT or WDS or PXE) which can automatically import computer on which TS runs into SCCM dataanse, so that I do not have to add computer information manually. I think I need to add custom hook to boot image for that. But can anyone provide me the script to add unknown computer to SCCM database.Divya
Free Windows Admin Tool Kit Click here and download it now
May 9th, 2011 7:37am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics