none
Write the computer description field in Active Directory RRS feed

  • General discussion

  • Hi Guys, 

    I'm complete newbie in scripts......

    I'm trying to complete the description field in AD with some relevant information, so can you help me?

    I've got this script from  "https://4sysops.com/archives/automatically-fill-the-computer-description-field-in-active-directory/"
    And i need to complete with Ethernet Mac Address Wi-Fi Mac Address, Date and time....

    Set WshNetwork = WScript.CreateObject("WScript.Network")
    Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    ' Get service tag and computer manufacturer
    For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
      serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
      manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")
    Next
    ' Get computer model
    For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")
      model = trim(replace(objComputer.Model, ",", "."))
    Next
    ' Get computer object in AD
    Set objSysInfo = CreateObject("ADSystemInfo")
    Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
    ' Build up description field data and save into computer object if different from current description
    ' We also do not update computers with a description that starts with an underscore (_)
    newDescription = WshNetwork.UserName & "|" & manufacturer & "|" & model & "|" & serviceTag & ""
    if not objComputer.Description = newDescription and not left(objComputer.Description,1) = "_"  then
      objComputer.Description = newDescription
      objComputer.SetInfo
    end if

    • Changed type Bill_Stewart Wednesday, May 30, 2018 6:40 PM
    • Moved by Bill_Stewart Wednesday, May 30, 2018 6:40 PM This is not "scripts on demand"
    Monday, March 26, 2018 8:04 PM

All replies