Asset Management Suite

 View Only

Custom Inventory for Computer AD Description 

Apr 20, 2011 04:01 PM

We populate the Active Directory Computer Description field on all of our servers and PCs when we deploy them . We used a custom inventory in NS6 to capture this information and use it in reports and collections. This article explains how to perform this custom inventory task in Symantec Management Platform 7.1 (NS7).

The basic steps to create a custom inventory are detailed in this article, HOWTO10487. Refer to this article for details on how to create a custom data class and custom inventory task.

First, create a custom Data Class. The Data Class name is AD Computer Description. There will be only one attribute, Description. Note that the GUID is auto-generated after you create the data class, add attributes, and save the data class. You will need to come back to this screen and copy the data class GUID to use in the script.

 

Custom Data Class

Next create the attribute Description. I used 90 as the length, this number can be adjusted to fit your environment. It is not the key.

Custom data class attribute

After you have saved the attribute and data class, remember to copy the GUID that is auto-generated. Select the custom data class from the list and click the hand icon to view the properties.

List of custom data classes

Next create a custom inventory. The easiest way is to clone an existing sample custom inventory. Give it a name, such as Custom Inventory - AD Computer Description. Make sure the script type is set to VBscript.

Copy and paste the VBscript into the script details window. You will need to change the GUID in the script. Note there are two GUIDs in the script, do not change the first one, change the one highlighted in the image below.

 

Here is the script listing. You can test the script from a command-line on any system with the Symantec Management Agent installed.

 'Following is a modified sample custom inventory script gathering information about the computer description of a machine
'and posting data to NS using Altiris NSE Component - no XML required!
'Original script by KSchroeder:
'https://www-secure.symantec.com/connect/downloads/custom-inventory-gather-ad-description-field
'===================================================================================================================

Option Explicit
On Error Resume Next
 
Dim oShell, oAdSysInfo,o
Dim sDN, sDescription

Set oShell = CreateObject("WScript.Shell")
Set oAdSysInfo = CreateObject("ADSystemInfo")
sDN = oAdSysInfo.ComputerName
Set o = GetObject("LDAP://" & sDN)

sDescription = o.Description
'Uncomment these lines if you are running the VBscript interactively for testing
'If sDescription <> "" Then
 'wscript.echo sDescription
'End If

Set oShell = Nothing
Set oAdSysInfo = Nothing
Set o = Nothing

'===================================================================================================================

'Create instance of Altiris NSE component
dim nse
set nse = WScript.CreateObject ("Altiris.AeXNSEvent")

' Set the header data of the NSE
' Please don't modify this GUID
nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
nse.Priority = 1

'Create Inventory data block. Here assumption is that the data class with below guid is already configured on server
dim objDCInstance
set objDCInstance = nse.AddDataClass ("{4f4e7e62-21c2-4e96-89c2-d1ef8068ee2c}")

dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)

'Add a new row
dim objDataRow
set objDataRow = objDataClass.AddRow
'Set columns
objDataRow.SetField 0, sDescription

nse.SendQueued

WScript.Quit(0)  

After you have changed the GUID and saved your task, do a Quick Run test on one of your systems. It should populate the table with data. I tested this by openng SQL Server Management Studio and creating a new query:

 SELECT * FROM Inv_AD_Computer_Description. 

This returned the three columns in the table, _id, _ResourceGuid, and Description.

At this point you should be able to schedule this task to run on a regular basis and gather this inventory information from your systems.

Statistics
0 Favorited
0 Views
1 Files
0 Shares
0 Downloads
Attachment(s)
txt file
AD Description script final.txt   1 KB   1 version
Uploaded - Feb 25, 2020

Tags and Keywords

Related Entries and Links

No Related Resource entered.