Updating Active Directory Computer Description Using SCCM and MDT

Updating Active Directory Computer Description Using SCCM and MDT
Updating Active Directory Computer Description Using SCCM and MDT

Estimated reading time: 2 minutes

You may have seen our previous post on how to set the local computer description during SCCM OSD (Operating System Deployment). Now, with the help of a script and Microsoft Deployment Toolkit (MDT), we can take that local computer description and use it as the Active Directory (AD) computer description.

Required Script

To achieve this, you’ll need the following script:

strModel = GetModelInfo
strLocalDescription = GetLocalDescription
strDescription = strLocalDescription & ” – ” & strModel
UpdateAD

Function GetModelInfo
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!” & strComputer & “\root\cimv2”)
Set colItems = objWMIService.ExecQuery(“Select * from Win32_ComputerSystem”)
For Each objItem in colItems
GetModelInfo = objItem.Model
Next
End Function

Function GetLocalDescription
strComputer = “.”
Set objWMIService = GetObject(“winmgmts:{impersonationLevel=impersonate}!” & strComputer & “\root\cimv2”)
Set colItems = objWMIService.ExecQuery(“Select Description from Win32_OperatingSystem”)
For Each objItem in colItems
GetLocalDescription = objItem.Description
Next
End Function

Sub UpdateAD
Set objSysInfo = CreateObject(“ADSystemInfo”)
On Error Resume Next
Set objComputer = GetObject(“LDAP://” & objSysInfo.ComputerName)
objComputer.Description = strDescription
objComputer.SetInfo
End Sub

Implementation Steps

Setting the Local Computer Description: Ensure that you have already set the local computer description step in your task sequence.

Running the Script: This Active Directory computer description step must go directly after the local computer description step. Ensure that MDT integration is enabled; otherwise, this process won’t work.

Saving the Script: Copy the script above into a text editor and save the file as setaddescription.vbs. Place the file into your MDT Scripts folder and update your MDT deployment within your Configuration Manager Console.

Creating the Task Sequence Step: Create a new step using the “Run Command Line” option. In the Command line area, enter the following:

cscript.exe "%DEPLOYROOT%Scripts\setaddescription.vbs"

Account Permissions: Ensure that you use a domain account with access to update Active Directory computer descriptions in the “Run this step as the following account” section on the step.

This process will now take your local computer description and copy it to the machine’s Active Directory computer description.

Comments

If you have any questions or comments on this guide, please feel free to leave us a message below using our comments system. We’ll respond as soon as possible!

Share this content:

Click to rate this post!
[Total: 1 Average: 5]
Avatar for Andrew Armstrong

About Andrew Armstrong

Founder of TechyGeeksHome and Head Editor for over 15 years! IT expert in multiple areas for over 26 years. Sharing experience and knowledge whenever possible! Making IT Happen.

View all posts by Andrew Armstrong

8 Comments on “Updating Active Directory Computer Description Using SCCM and MDT”

  1. can we also use this script to just pass the description you want and not look at the local computer description?
    ex: cscript script.vbs “JoBlo Dell 1234”

    Thanks

    1. Completely untested but you could change the script here:

      strDescription = strLocalDescription & ” – ” & strModel

      to

      strDescription = “WHATEVER YOU WANT TO CALL IT”

  2. can we also use this script to just pass the description you want and not look at the local computer description?
    ex: cscript script.vbs “JoBlo Dell 1234”

    Thanks

    1. Completely untested but you could change the script here:

      strDescription = strLocalDescription & ” – ” & strModel

      to

      strDescription = “WHATEVER YOU WANT TO CALL IT”

Leave a Reply

Your email address will not be published. Required fields are marked *