Intel,Altiris Group

  • 1.  CUSYOM INVENTORY SCRIPT VB and Powershell

    Posted Aug 14, 2014 12:49 PM

    Am not getting any data posted from custom inventory I created.

    'Following is a custom inventory sript gathering information about Java Runtime Environment of a machine and posting data
    'to NS using Altiris NSE Component
    '===================================================================================================================
    On Error Resume Next

    const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
    Set oReg=GetObject( _
       "winmgmts:{impersonationLevel=impersonate}!\\" &_
        strComputer & "\root\default:StdRegProv")
    strKeyPath = "SOFTWARE\JavaSoft\Java Runtime Environment"
    strValueName1 = "Java7FamilyVersion"
    strValueName2 = "Java6FamilyVersion"


    oReg.GetStringValue _
       HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,stringJava7FamilyVersion
    oReg.GetStringValue _
       HKEY_LOCAL_MACHINE,strKeyPath,strValueName2,stringJava6FamilyVersion
    if isnull(stringJava7FamilyVersion) then
      stringJava7FamilyVersion= "missing"
    end if

    if isnull(stringJava6FamilyVersion) then
      stringJava6FamilyVersion = "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 ("{ec0aba6b-73e7-4854-968a-bfc4a3505b66}")

    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)

    'Add a new row
    dim objDataRow
    set objDataRow = objDataClass.AddRow
    'Set columns
    objDataRow.SetField 0, stringJava7FamilyVersion
    objDataRow.SetField 1, stringJava6FamilyVersion
    nse.SendQueued

    Any Ideas why?

    Condidered trying this with POwershell but not reall sure to how to go about it besdides the query part

    Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{81BE0B17-563B-45D4-B198-5721E6C665CD}" -Name Displayversion,DisplayName

    Any help is appreciated

     

     



  • 2.  RE: CUSYOM INVENTORY SCRIPT VB and Powershell

    Posted Aug 14, 2014 12:51 PM

    I actually cloned that script from a workin one and modified it to gather info about Microsoft Lync



  • 3.  RE: CUSYOM INVENTORY SCRIPT VB and Powershell

    Posted Aug 14, 2014 12:54 PM

    Crap,I posted wrong script,here is correct one

     

    'Following is a custom inventory sript gathering information about Microft Lync 2010 of a machine and posting data
    'to NS using Altiris NSE Component
    '===================================================================================================================
    On Error Resume Next

    const HKEY_LOCAL_MACHINE = &H80000002
    strComputer = "."
    Set oReg=GetObject( _
       "winmgmts:{impersonationLevel=impersonate}!\\" & _
        strComputer & "\root\default:StdRegProv")
    strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{81BE0B17-563B-45D4-B198-5721E6C665CD}"
    strValueName1 = "DisplayName"
    strValueName2 = "DisplayVersion"


    oReg.GetStringValue _
       HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,stringDisplayName
    oReg.GetStringValue _
       HKEY_LOCAL_MACHINE,strKeyPath,strValueName2,stringDisplayVersion
    if isnull(stringDisplayName) then
      stringDisplayName= "missing"
    end if

    if isnull(stringDisplayVersion) then
      stringDisplayVersion = "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 ("{6d4797b0-39c2-4abf-8579-676f98a48697}")

    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)

    'Add a new row
    dim objDataRow
    set objDataRow = objDataClass.AddRow
    'Set columns
    objDataRow.SetField 0, stringDisplayName
    objDataRow.SetField 1, stringDisplayVersion
    nse.SendQueued

     



  • 4.  RE: CUSYOM INVENTORY SCRIPT VB and Powershell

    Posted Aug 14, 2014 03:23 PM

    I don't see any glaring errors.  Double-check you have the correct Guid for the custom data class.  Can you post a screen shot of the custom data class configuration?

    Any reason why you don't just use the built in hardware inventory?  It will gather the ARP data from the exact keys you are doing a custom query on, then you can query the installed version for any software, not just Lync without the need to create custom data classes.



  • 5.  RE: CUSYOM INVENTORY SCRIPT VB and Powershell

    Posted Aug 20, 2014 09:52 PM

    A couple of things come to mind.

    1. Based on what @JoeVan stated, whenever changes are made to a Custom Data Class the GUID for it changes. 6d4797b0-39c2-4abf-8579-676f98a48697 may have changed.
    2. Instead of attempting to upload the created XML to the server, Review it first.

      Comment out the last line like so:

      'nse.SendQueued

      Then add a last line like so:

      WScript.Echo nse.Xml

      Run the script using cscript.exe like so:

      cscript.exe /nologo script.vbs (script name may vary)

    Let us know if we can be of more assistance.



  • 6.  RE: CUSYOM INVENTORY SCRIPT VB and Powershell

    Broadcom Employee
    Posted Aug 21, 2014 03:38 AM
      |   view attached

    One of my customer is facing a similar issue, they want to search a file with a particular ext (*.KMT). Full / File Inventory doesn't detect it. Below is the Vb script and Data Class screenshot.

    '**********************************************************************************
    'Copyright Symantec Corporation - Altiris Business Unit - 2007
    'May be used with permission from copyright holder
    'Author: Douglas Jenkins
    'Created: December 2007
    'Modifications:
    ' 20080108: Modified to process an array of specified paths rather than a single drive
    '           Removed the ProcessDrive subroutine
    '           Call ProcesFolders subroutine from main For loop rather than ProcessDrive subroutine
    '           Modified exclusion logic to use an array and the InStr function
    ' 20091022  Update for NS7
    '**********************************************************************************
    '
    ' END-USER INSTRUCTIONS:
    ' Please make the following changes as per your requirements in your environment.
    ' All changes to be made are in the 'User Customization Section'.
    '    1. Modify the 'folders2Scan' array to contain the list of desired folders. REQUIRED.
    '    2. Modify the 'folders2Exclude' array by adding or removing directories to be excluded. REQUIRED.
    '    3. Modify the dataClassName, as desired. This is not required.
    '    4. Modify the nsi output path, as desired for testing. This is not required.
    ' No other modifications should be required
    '**********************************************************************************

    dim folder, curDrive


    '**********************************************************************************
    ' User Customization Section - Please make changes within this section only
    '**********************************************************************************

    'Array of folders to scan. ONLY the folders listed in this array will be scanned. Subdirectories of these
    '  folders can be excluded, below.
    '  The array is zero-based, so an array of (2) can contain three items.
    '  THE ARRAY SIZE VALUE MUST MATCH THE NUMBER OF ITEMS IN THE LIST.
    '  ITEMS IN THE LIST MUST BE NUMBERED SEQUENTIALLY BEGINNING AT 0.
    '  Root folders do not have a 'size' or 'datelastaccessed' value. If specified, there will be no entry created
    '  for the root folder. However, all folders within the root of the drive will be processed unless excluded.
    Dim folders2Scan(3)
    folders2Scan(0) = "c:\test\"
    folders2Scan(1) = "C:\test\2SU00.KMT"
    folders2Scan(2) = "C:\test\5SU00.KMT"
    folders2Scan(3) = "C:\"


    'Array of folders to EXCLUDE
    '  The entry can be a complete path, a complete folder name, a partial path or partial folder name. Be careful.
    '  Any folder name containing these strings will be excluded. Sub-folders will also be excluded.
    '  This has priority over the folders2Scan entries.
    '  This script uses the InStr function. We will look for the following strings in each path scanned.
    '  This array allows for exclusion of system folders and specific subfolders within a folder to be scanned.
    '  We recommend preserving the first three exclusion array entries as scanning certain system folders may
    '  cause the script to abort.
    '  The array is zero-based, so an array of (2) can contain three items.
    '  THE ARRAY SIZE VALUE MUST MATCH THE NUMBER OF ITEMS IN THE LIST.
    '  ITEMS IN THE LIST MUST BE NUMBERED SEQUENTIALLY BEGINNING AT 0.
    '  These entries are NOT case-sensitive.
    Dim folders2Exclude(3)
    folders2Exclude(0) = "System Volume Information"
    folders2Exclude(1) = "recycler"
    folders2Exclude(2) = "msocache"
    folders2Exclude(3) = "C:\mystuff\picnix48\source"


    '**********************************************************************************
    ' End of User Customization Section - no other changes should be made
    '**********************************************************************************

    ''' Altiris Stuff
    '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 ("{03ecd975-4923-476d-8161-6815cf30a571}")

    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)
    ''' End of Altiris Stuff

    'process all folders specified in the folders2Scan array and create nsi output
    For Each path In folders2Scan
        'Wscript.echo "Processing array: Path=" & path
        Call ProcessFolders(path)
    next

    ''' Altiris Stuff
    ' Send the NSE data to the NS server
    nse.SendQueued
    ''' End of Altiris Stuff
    ''' End of vbscript main logic

     

    '*******************************************************************************************************************
    '*** Subroutines                                                                                                   *
    '*******************************************************************************************************************

    Sub ProcessFolders(path)
    'Wscript.echo path

        'skip excluded folders
        validFolder = 1
        For Each exFolder in folders2Exclude
            exFoundValue = InStr(UCASE(path), UCASE(exFolder))
            if exFoundValue <> 0 then validFolder = 0
            'Wscript.echo "  exFolder=" & exFolder & ": exFoundValue=" & exFoundValue & " and validFolder=" & validFolder
        next
        'Wscript.echo " "

        if validFolder then
            Set fs = CreateObject("Scripting.FileSystemObject")
            set folder = fs.GetFolder(path)
            'Wscript.echo "folder.Path=" & folder.Path

            ' Root folders do not have size nor datelastaccessed. Don't create a record for them.
            if folder.IsRootFolder = false then
                ''' Altiris Stuff '''
                  'Add a new row
                  dim objDataRow
                  set objDataRow = objDataClass.AddRow
                  'Set columns
                  objDataRow.SetField 0,  ToXmlString(folder.Name)
                  objDataRow.SetField 1,  ToXmlString(folder.Path)
                  objDataRow.SetField 2,  ToXmlString(folder.Size)
                  objDataRow.SetField 3,  ToXmlString(folder.DateLastAccessed)
                  ''' End of Altiris Stuff '''
            end IF

            ' Recurse through all subfolders
            For each item in folder.SubFolders
                ProcessFolders(item.Path)
            Next
            set folder = Nothing
        end IF
    End Sub


    Function ToXmlString (strInput)
      Dim strOutput
      If (IsNull(strInput)) Then
        ToXMLString = strInput
      Else
        strOutput = Replace(strInput, "&", "&amp;")
        strOutput = Replace(strOutput, """", "&quot;")
        strOutput = Replace(strOutput, "<", "&lt;")
        ToXmlString = Replace(strOutput, ">", "&gt;")
      End If
    End Function