• November 2008
    M T W T F S S
    « Sep   Jul »

Naming Computers and LANDesk OSD

LANDesk puts out a technical paper on how to accomplish Hardware Independent Imaging with its Management Suite.  If you don’t know what HII is, basically it is the process of creating a single image or imaging task that will work regardless of your hardware.  LANDesk’s tools plus Sysprep create a very easy to maintain HII imaging solution.  However, I wanted to add a little piece of of my own to this mix.

We have a newly implemented naming convention here at CSN.  This was very thoroughly thought out by many people, but more or less the naming convention identifies a computer’s location, and its asset tag number.  With the documentation on HII that LANDesk provides, a computer must be named properly in the LANDesk database, or named after the imaging task has finished.  Since our computers move from one location to another quite often, and renaming computers in the LANDesk database is not easy, I created a way for technicians to name the computer before the imaging process begins.  Once named, the computer images, and reboots into Sysprep where it joins the domain and installs all of its device drivers.  Wonderful!

Now, if you are not familiar with LANDesk, a lot of this won’t make sense.  Basically, LANDesk OSD scripts are a text file which you can alter to your liking much like any other scripting method.  Now, to get started with adding dynamic renaming to the script, I enter the following command into the LANDesk OSD script in the part just before the imaging command is executed:

REMEXEC259=sdclient /f /o /dest="X:\ldclient\pcname.vbs" /p="http://server/PC_Rename/pcname.vbs", STATUS

SDCLIENT.EXE is the swiss army knife utility of LANDesk.  It does lots of stuff.  Here it just copies a file from an HTTP share onto the WinPE environment.  I then add another line right underneath the one I just created that will execute the pcname.vbs script that was just copied from a server:

REMEXEC260=cscript x:\ldclient\pcname.vbs

So, let’s take a look at the contents of the pcname.vbs file.  Keep in mind that I do have a programming educational background, but I’ve never done any vbscripting before this, so the script may not be the most elegant vbscript around:

Dim objShell
Dim getName
Dim objFSO
Dim f

Set objShell = WScript.CreateObject("WScript.Shell")
getName = InputBox("What is the computer's name? Press Cancel to rename and rejoin the Domain later.")

set objFSO = CreateObject("Scripting.FileSystemObject")
set f = objFSO.CreateTextFile("x:\\LDClient\\insertname.bat", 2)
If getName <> "" Then
f.WriteLine("tokreplw c:\sysprep\sysprep.inf COMPUTERNAME=" & getName)
f.WriteLine("tokreplw C:\sysprep\sysprep.inf COMPUTERNAME=%Computer - Device Name%")
End If

So, for a rough explanation of this vbscript.  First, an input box is called, which prompts the technician to input the computer’s name.  Whatever the user enters is returned to the variable “getName”.  A batch file is created that will get executed by the LANDesk OSD script later, “insertname.bat”.  If the user enters something, then the batch file is created with a single tokreplw command containing the text as an argument to the tokrepw command.  If the user does not enter anything, or presses cancel, then the batch file gets created with the original naming command that LANDesk put into the script originally.  I’ll go into tokreplw in a later post.

I mentioned that LANDesk creates its own naming command. Let me expand on that. By default, LANDesk attempts to find the name of the computer in the LANDesk database and name the computer for us.  The line that LANDesk puts into the OSD script when you initially create the OSD task in the LANDesk Management Suite Console looks like this (note that when you create a LANDesk OSD script, you do not see the actual text of the script. Instead, the LANDesk administrator uses a GUI wizard to create the OSD script. The OSD script can be opened in a text editor by selecting the OSD task and selecting “Advanced Edit”):

REMEXEC29=tokreplw C:\sysprep\sysprep.inf COMPUTERNAME=%Computer - Device Name%

Looks very similar to the contents of our batch file, doesn’t it?  We simply remove the command for REMEXEC29, and replace it with the execution of our batch file:

REMEXEC29=cmd /c x:\ldclient\insertname.bat

Instead of the computer getting the name that LANDesk thinks it should have, the technician can specify the name that the computer actually needs to have.  Since our computers move around a lot, their names change a lot.  This is convenient for our environment.

Well, that is all for now.  If I get a moment or two, I will try to pump out a post about the mysterious tokrepw program. 🙂


3 Responses

  1. Very cool stuff, I hope to try this soon.

    Bit of clarification though, HII is not provided by LANDesk, it’s done by a group of LANDesk users & engineers on their own time and posted/hosted at droppedpackets.org

  2. Very interesting, thanks for sharing.

    an extra tip, you can convert your vbscript into EXE using this online vbscript converter.

  3. […] Computers in LANDesk Upgrade Posted on August 19, 2009 by dantheman13 Late last year I wrote an article on how to rename computers before an image is applied during LANDesk’s OSD […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: