How to use Custom Inventory to collect ODBC DSN information for computers
search cancel

How to use Custom Inventory to collect ODBC DSN information for computers


Article ID: 175194


Updated On:


IT Management Suite Inventory Solution


ITMS Inventory Solution Custom Inventory can be used to gather Open Database Connectivity (ODBC) data source names (DSNs) from computers if present. This article presents a sample custom inventory PowerShell script and custom report that displays the custom inventory data. Please note that Symantec Support does not support custom scripting or reporting, so modifications to the script and report must be made by the user. For more information on creating custom inventories, see this article: Introduction to Custom Inventory in Notification Server 8.x [Altiris]


Altiris Inventory Solution


Create a new custom data class that will store the ODBC DSN information for each computer.

Go to Settings > All Settings then Settings > Discovery and Inventory > Inventory Solution > Manage Custom Data Classes.

Click New data class.

Name the data class something appropriate (this example uses "DSN Names") and click OK.

Click Add add each attribute (column) below. For all attributes, select no for Key and Required, and leave the size at default. Be sure to add them in the following order - you can move and edit existing attributes, but only before the data class has data.

Computer Name

DSN Name

Driver Name

DSN Type

Inventory Date (agent local)

Verify that all attributes are in the correct order (Computer Name at the top) and that all have Key and Required set to no.

Save changes.

Create a Custom Inventory Script Task.

Go to Manage > Jobs and Tasks.

Browse the folder drop-down menu to an appropriate folder to create the custom inventory script task under.

Right-click on the folder, then select New > Task.

Select the Run Script task.

Name the task appropriately.

Select Script type: PowerShell

Copy and paste the entire PowerShell script below into the large text box of the script task


------------------------------------ Start Of Script ------------------------------------

# Altiris Custom Inventory: PowerShell script to inventory ODBC DSN Names

$Computer = hostname

$nse = New-Object -com Altiris.AeXNSEvent

# Please don't modify this GUID -->

$nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"

$nse.Priority = 1


# Modify this variable with the custom data class GUID

$objDCInstance = $nse.AddDataClass("{paste the GUID here between braces}")


$Flag = 0

$DSNs = Get-OdbcDsn

$objDataClass = $nse.AddDataBlock($objDCInstance)

foreach ($DSN in $DSNs)


            if ($Flag -eq 0) {

                        $Flag = 1


            $objDataRow = $objDataClass.AddRow()

            $objDataRow.SetField(0, $Computer )

            $objDataRow.SetField(1, $DSN.Name )

            $objDataRow.SetField(2, $DSN.DriverName )

            $objDataRow.SetField(3, $DSN.DsnType )

            $objDataRow.SetField(4, $((Get-Date).ToString()) )


if ($Flag -eq 0) {

$objDataRow = $objDataClass.AddRow()

$objDataRow.SetField(0, $Computer )

$objDataRow.SetField(1, "None Found" )

$objDataRow.SetField(2, "n/a" )

$objDataRow.SetField(3, "n/a" )

            $objDataRow.SetField(4, $((Get-Date).ToString()) )


# send the data


------------------------------------ End Of Script ------------------------------------

Return to the custom data class you created above, highlight the data class name, and click the hand icon above the list of data classes. Copy the GUID and paste it into the script at this location - leave the braces.

$objDCInstance = $nse.AddDataClass("{paste the GUID here between braces}")

It will look like this for example

$objDCInstance = $nse.AddDataClass("{27b9d8d3-975f-4f29-af07-f7085acd2791v}")

In the task, click Advanced and on the Script tab, and set the Show script: drop down to Hidden.

Target a test computer and run the task - verify the task runs on the client successfully with no pop-ups. If it fails, check credentials used in Advanced > Run tab and/or the script for copy/paste errors.

Return to the custom data class, select the hand icon again, and copy the Table Name. For our example it is Inv_DSN_Name.


Navigate in the console to Reports > All Reports, and your custom report folder. You can create folders and subfolders by right-clicking the Reports container at the top, selecting New > Folder. Then right-click the custom report folder and select New > Report > SQL Report. When the new report loads, give it a name such as DSN Name Report. Delete the existing SQL code in the report and type in this:

            Select * from Inv_DSN_Name

Click the Save Changes button. You should see data from your test, provided that it ran successfully. Once everything looks good, target the desired computers in the Custom Inventory task.


Additional Information

NOTE: Symantec Support does not support custom scripting or reporting. Modifications to the script and report must be made by the user. Please contact Symantec Consulting Services for assistance with creating custom inventory scripts or custom reports, who can be reached at: