Video Screencast Help

Custom Inventory Solution 7 Script Examples

Created: 09 Nov 2010 | 6 comments
Language Translations
ajdavis's picture
+7 7 Votes
Login to vote

Please see the attached ZIP file as it contains many Custom Inventory Solution 7 VBScript examples.  Many of the custom inventory scripts would need to be slightly modified in order to work in your environment but should provide a good starting framework.  We use custom inventory a lot for configuration management purposes to ensure that all of our systems are configured the same way.  The scripts are very elementary and likely not as efficient as they should be as I am by no means a scripting guru.

You will of course need to create an associated custom data class for each script and update the GUID in the script to reference the data class.

 

Create a Data Class and Obtain GUID:

Data Class

 

Update Script with Data Class GUID:

Script

 

Update Script with Data Class Field Info:

Script

 

LocalUserAccounts.vbs

Performs a WMI query that pulls back information about all the local user accounts on a system.

 

OsInstallDate.vbs

Performs a WMI query and pulls back the date and time the system was built.

 

TecAdapterMonitoring.vbs

Opens a text based configuration file (tecad_win.conf) and pulls back values within the configuration file.

 

IIsFtpServerSettings.vbs

Performs a WMI query and pulls back IIS FTP Server Settings

 

NicTeaming.vbs

This script for HP Servers only.  It searches the registry to see if the server has teamed NICS and reports the configuration.  It reports if the NICs are teamed, number of adapters in the team, teaming configuration, and the operating mode value.

 

OSRecoveryConfiguration.vbs

Performs a WMI query and pulls back information about the recovery options configured on the system.  For example, Debug File Path, AutoReboot, Mini Dump Directory, etc.

 

IIsFtpVirtualDirSettings.vbs

Performs a WMI query and pulls back information about the IIS Virtual Directory Settings

 

NTEventLogFile.vbs

Performs a WMI query and pulls back information about how the system event logs are configured.

 

SNMPConfiguration.vbs

Searches the registry for SNMP configuration settings.  For example, community string, security configuration, and trap destinations.

  

CompDesc.vbs

Searches Active Directory for the computers description recorded in AD.  The script then creates/updates a registry key locally on the system that includes the computers AD description.  This script would need to be modified a little to search the appropriate OU and domain structure for your organization.

 

IIsIsolationMode.vbs

Performs a WMI query and pulls back whether or not IIS isolation mode is enabled.

 

OsBuild.vbs

Searches for a specific registry keys and brings back their value.

 

Variables.vbs

Searches the registry for specific system environment variables and pulls back the values

 

Uptime.vbs

Uses uptime.exe to bring back information about System Availability including Total Uptime, Total Downtime, Total Reboots, Mean Time Between Reboots and Total Bluescreens.  The script is configured to pull this information for the past 30 days but that value is changeable.  The script launches uptime.exe and writes the results to an .INI file and then the script reads the .INI file to obtain the values.

Comments 6 CommentsJump to latest comment

JeffDG's picture

One of the ncie things in V7 was the move from the "dark art" XML format for Custom Inventory to the more standard VBS.  I've even manged to get the custom inventory DLLs to work inside a fully featured C# application for gathering information from users (then storing it as part of a Custom Inventory class).

 

Thanks for sharing.

0
Login to vote
ajdavis's picture

Have you had a need to collect custom inventory on systems that don't have the Symantec Management Agent installed?  I find it kind of frustrating that you can't use the same custom inventory scripts on agent and agent-less systems.  I was expecting a method for integrating the custom inventory scripts with the agent-less inventory package.  I have not been able to find a viable workaround for this limitation yet.

0
Login to vote
JacquesPLoubser's picture

Thanks for this! Just a quick question, would I have to create a custom table in the SQL DB for this info to be stored in as well?

0
Login to vote
toca's picture

Thanks AJ,

This is helpful and definitley put me on the correct path.

I changed the os build vbs for my needs but it's not working.

what i'm trying to do is query the "font" information in the registry and let that populate that into the altiris database.

I think i'm going wrong with the creation of my data class ( screenshot attached)

and with my script ( it fails on line 45)

Can anyone have a look and see if i'm on the right path....

script:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

'Gather registry key value from machine and posting data to NS using Altiris NSE Component
'===================================================================================================================
'      On Error Resume Next

const HKEY_CURRENT_USER = &H80000002

strComputer = "."
Set oReg=GetObject( _
   "winmgmts:{impersonationLevel=impersonate}!\\" &_
    strComputer & "\root\default:StdRegProv")
strKeyPath = "Software\Microsoft\Office\9.0\Excel\Options"
strValueName1 = "Font"
oReg.GetStringValue _
   HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,stringfont

'WScript.Echo "Font: " & stringfont

if isnull(stringfont) then
  stringrequestid = "missing"
end if

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

'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 ("{e401a979-4799-4053-9fbc-e2726d7335b6}")

dim objDataClass
set objDataClass = nse.AddDataBlock (objDCInstance)

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

nse.SendQueued

custom data class.JPG registry path.JPG
0
Login to vote
Dustin Perkins's picture

Without looking to much into it (as I'm new to custom inventory scripts), I can see one thing:

When you use the oReg.GetStringValue method, you reference HKEY_LOCAL_MACHINE but up above you only have HKEY_CURRENT_USER (which has HKLM's value already) declared.

Change HKEY_CURRENT_USER to HKEY_LOCAL_MACHINE on line 5 and see if that helps..

Hope it helps...

P.S. See http://blogs.msdn.com/b/alejacma/archive/2008/04/11/how-to-read-a-registry-key-and-its-values.aspx for more info on using these methods...

0
Login to vote
ajdavis's picture

Toca,

Back in the day when you created a new data class the fields started with 0 but I believe they now may start with 1.

Try changing the SetField number from 0 to 1.

Original:  objDataRow.SetField 0, stringfont

New:  objDataRow.SetField 1, stringfont

Did that work?

0
Login to vote