Hi<\/p>\n
we currently use this script to add last logon information , make model, serial number to description box in AD. is it possible to add the OS and version to it at the end please.<\/p>\n
On Error Resume Next\n\nSet objWMIService = GetObject(\"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2\")\nSet colcomputersystem = objWMIService.ExecQuery(\"Select * from Win32_computersystem\")\nSet colBIOS = objWMIService.ExecQuery(\"Select * from Win32_BIOS\")\nFor each objcomputersystem in colcomputersystem\nGetcomputersystem = objcomputersystem.Model\nGetComputerManufacturer = objcomputersystem.Manufacturer\nNext\nFor each objBIOS in colBIOS\nGetSerialNumber = objBIOS.SerialNumber\nNext\nDim objSysInfo, objUser\nSet objSysInfo = CreateObject(\"ADSystemInfo\")\nSet objUser = GetObject(\"LDAP://\" & objSysInfo.UserName)\nSet objComputer = GetObject(\"LDAP://\" & objSysInfo.ComputerName)\nDim sSiteName : sSiteName = objSysInfo.SiteName\nIf Err Then\n\tsSiteName = \"Unknown\"\n\tErr.Clear\nEnd If\n \nif LCase(GetComputerManufacturer)=\"lenovo\" then\nSet colItems = objWMIService.ExecQuery(\"SELECT * FROM Win32_ComputerSystemProduct\")\nFor Each objItem in colItems\nstrModel = \"Lenovo \" & objItem.Version\nExit For\nNext\nGetcomputersystem = strModel & \" (\" & Getcomputersystem & \")\"\nend if\nSet colOSes = objWMIService.ExecQuery(\"Select * from Win32_OperatingSystem\") \nFor each objOS in colOSes\nGetOS = objOS.caption\nGetArch = objOS.OSArchitecture\nNext\nstrMessage = \"SN: \" & GetSerialNumber & \" --- Last Logon : \" & objUser.displayName & \" @ \" & Date & \" - \" & Left(Time,5) & \" / Model: \" & Getcomputersystem & \" / Site: \" & sSiteName\nobjComputer.Description = strMessage\nobjComputer.SetInfo\n<\/code><\/pre>\n
Advertisement
thank you<\/p>","upvoteCount":5,"answerCount":18,"datePublished":"2025-07-23T16:55:28.422Z","author":{"@type":"Person","name":"shabs","url":"https://community.spiceworks.com/u/shabs"},"suggestedAnswer":[{"@type":"Answer","text":"
Hi<\/p>\n
we currently use this script to add last logon information , make model, serial number to description box in AD. is it possible to add the OS and version to it at the end please.<\/p>\n
On Error Resume Next\n\nSet objWMIService = GetObject(\"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2\")\nSet colcomputersystem = objWMIService.ExecQuery(\"Select * from Win32_computersystem\")\nSet colBIOS = objWMIService.ExecQuery(\"Select * from Win32_BIOS\")\nFor each objcomputersystem in colcomputersystem\nGetcomputersystem = objcomputersystem.Model\nGetComputerManufacturer = objcomputersystem.Manufacturer\nNext\nFor each objBIOS in colBIOS\nGetSerialNumber = objBIOS.SerialNumber\nNext\nDim objSysInfo, objUser\nSet objSysInfo = CreateObject(\"ADSystemInfo\")\nSet objUser = GetObject(\"LDAP://\" & objSysInfo.UserName)\nSet objComputer = GetObject(\"LDAP://\" & objSysInfo.ComputerName)\nDim sSiteName : sSiteName = objSysInfo.SiteName\nIf Err Then\n\tsSiteName = \"Unknown\"\n\tErr.Clear\nEnd If\n \nif LCase(GetComputerManufacturer)=\"lenovo\" then\nSet colItems = objWMIService.ExecQuery(\"SELECT * FROM Win32_ComputerSystemProduct\")\nFor Each objItem in colItems\nstrModel = \"Lenovo \" & objItem.Version\nExit For\nNext\nGetcomputersystem = strModel & \" (\" & Getcomputersystem & \")\"\nend if\nSet colOSes = objWMIService.ExecQuery(\"Select * from Win32_OperatingSystem\") \nFor each objOS in colOSes\nGetOS = objOS.caption\nGetArch = objOS.OSArchitecture\nNext\nstrMessage = \"SN: \" & GetSerialNumber & \" --- Last Logon : \" & objUser.displayName & \" @ \" & Date & \" - \" & Left(Time,5) & \" / Model: \" & Getcomputersystem & \" / Site: \" & sSiteName\nobjComputer.Description = strMessage\nobjComputer.SetInfo\n<\/code><\/pre>\nthank you<\/p>","upvoteCount":5,"datePublished":"2025-07-23T16:55:28.490Z","url":"https://community.spiceworks.com/t/vb-script-to-add-os-and-version-to-ad-description-field/1226340/1","author":{"@type":"Person","name":"shabs","url":"https://community.spiceworks.com/u/shabs"}},{"@type":"Answer","text":"