SCCM – Set Active Directory Computer Description

sccm logo

Last updated on April 17th, 2023 at 12:17 am

Read Time:1 Minute, 47 Second

So you may have seen our previous post on how to set the local computer description during SCCM OSD. Well now, with a little help from a script and MDT, we can take that local computer description and make that the Active Directory computer description.

To do this, you first need the required script, which you can get below:

 strModel = GetModelInfo  
 strLocalDescription = GetLocalDescription  
 strDescription = strLocalDescription & " - " & strModel  
 UpdateAD  
 Function GetModelInfo    
     strComputer = "."   
     Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!" & strComputer & "rootcimv2")  
     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 & "rootcimv2")  
           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  

Once you have this, you also need to ensure that you have set the local computer description step in your task sequence and then this Active Directory computer description step must go directly after the set local computer description step. You must also make sure you have MDT integration on or this will not work.

Copy the script above into a text editor and save the file as setaddescription.vbs and put it into your MDT Scripts folder and update your MDT deployment in your Configuration Manager Console.

Once all the pre-reqs are complete, you now need to create a new step using the “Run Command Line” option. You then need to enter the follow in the Command line area:

 cscript.exe "%DEPLOYROOT%Scriptssetaddescription.vbs"  

You also need to 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 will now take your local computer description and copy it to the machines 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.

Click to rate this post!
[Total: 0 Average: 0]

Free Subscription

If you want to be notified when we post more quality guides like this one, sign up to our free subscription service and you will receive an email when a new post is live.

Join 441 other subscribers.

No need to worry, we will not be filling your inbox with spam and you can unsubscribe anytime you like.


8 thoughts on “SCCM – Set Active Directory Computer Description

  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 us a message...

This site uses Akismet to reduce spam. Learn how your comment data is processed.