SCCM – Set Active Directory Computer Description

sccm

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 Disqus system.


You might also like...

4 Responses

  1. BRUCE SA says:

    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

    • tghadmin says:

      Completely untested but you could change the script here:

      strDescription = strLocalDescription & ” – ” & strModel

      to

      strDescription = “WHATEVER YOU WANT TO CALL IT”

  2. Naren says:

    Hi ,Could you please tell me how to get this done without having MDT integrated ?

Leave us a message...

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