Updating the description attribute during Specops Deploy/OS installations

(Last updated on January 27, 2021)

Here’s a great example of the benefits of integrating with standard Microsoft components rather than building stand-alone systems for everything.

Happy Specops customer James Prudente of Islip Public Schools wrote us to share how he extended the MDT task sequences used by Specops Deploy during operating system installations to also update the computer description attribute in Active Directory with data from the installation. Thanks for sharing, James!

Updating the description attribute during Specops Deploy/OS installations

The deployment product we used before we switched to Specops Deploy/OS required some post-installation cleanup, which meant a tech needed to touch every freshly imaged PC. We had created a script to automate some of that cleanup, and one of the things the script did was populate the “Description” field in Active Directory (AD) with basic information including the date the system was imaged. Since Deploy/OS automates the imaging process from start to finish we no longer needed to touch every PC, and once we stopped using the script we wanted to find an alternate way to populate AD with the desired information.

Because Deploy/OS is built on the Microsoft Deployment Toolkit (MDT), if you don’t mind working directly with MDT you can gain added functionality that allows you to do things that can’t be done natively through Deploy. The initial idea for doing so started with another Specops blog post which provides instructions on how to display additional computer information during the imaging process. I suggest reviewing that post as well.

The solution I put together borrows liberally from two other blogs, and the scripts themselves are almost entirely the work of their respective posters. MaikKoster’s blog provided information on setting the computer description in AD via a web service, which I’m sure works well but seemed overly complicated for our needs. Johan Arwidmark’s blog actually references Koster but provides a means to set the description without a web service. Arwidmark however was getting the computer description either from the MDT database or through the MDT wizard, neither of which is exposed to the end user with Deploy / OS.

I wanted a self-contained solution, where the MDT task would as part of its sequence create the description and then set it without any additional intervention. By piecing together the two blog posts and the code they provide, I was able to accomplish just that.

In brief, we are going to add three scripts to the sequence: one to create the desired description, and then one each to set this description on the local PC and in AD. These could be combined into one larger script, but I chose to keep them separate for clarity and troubleshooting purposes. Download the three scripts here, and save them to the <InstallationDrive>SpecopsDeployDeploymentRepositoryScripts directory on your Specops Deploy Image Server. These are WSF scripts, but if you are familiar with VBScript, you’ll easily be able to make sense of the code.

You may want to change line 71 (which begins with “sDescription=”) in “ZTICreateComputerDescription.wsf” to set the description exactly as you want it to appear. By default it will set the description to make, model, serial, and an install date as shown below:

Dell Inc. OptiPlex 990 SN: 12345678 Installed on 2/13/2013

AndrewBarnes has a great post showing how to determine what variables are accessible to your scripts if you want to make any changes.On the Specops Deploy / OS Image Server, open the Microsoft Deployment Toolkit Deployment Workbench.Open a Deployment Share and navigate to the Specops Deployment Respository which resides in InstallationDrive>SpecopsDeployDeploymentRespository.

Navigate to the Task Sequences node, right-click on the installation sequence you want to modify, and click Properties. Note that you will need to make the changes below to every installation task sequence for which you want the computer description displayed.

Click the Task Sequence tab, then navigate to the State Restore à Custom Tasks folder. We are going to create three custom tasks in this folder.

Click  Add – General – Run Command Line

Name the task “Set Computer Description” and in the command line field enter:

cscript “%SCRIPTROOT%ZTICreateComputerDescription.wsf”

Click the Options tab and check “Continue on error.” This will prevent the task from failing in case there is an error with the WSF script.

Now we need to create another “Run Command Line” task using the same process.

Name  this task “Set Computer Description in AD” and in the command line field enter:

cscript.exe “%SCRIPTROOT%ZTISetComputerDescriptionInAD.wsf”

Setting the AD Description requires that this script run as a domain user with the appropriate permissions.

Check “Run this step as the following account” then click “Set…” and enter a username and password. I used a domain admin account for this. Be sure to also check “Load the user’s profile.”

Click the Options tab and check “Continue on error.”One more script . . . Create another”Run Command Line” task using the same process.Name this task ”

Set computer Description in on Local PC” and in the command line field enter: cscript.exe “%SCRIPTROOT%ZTISetComputerDescriptionLocally.wsf”

Click the Options tab and check “Continue on error.”

Click OK to close out the task sequence. You can then exit the Deployment Workbench.

Lastly, open the Deploy/OS Admin tools, select the Image server, then “Publish Deployment Repository” to push your changes to your Deployment servers.

If everything went well, the next time you image a machine you will see AD populated with the information configured in the “ZTICreateComputerDescription.wsf” script.

I hope this post is helpful for some of you. Please reply with any questions and I’ll do my best to answer them.

Tags: , ,

Written by

James Prudente

Back to Blog