IT Management Suite

Expand all | Collapse all

Custom Inventory

  • 1.  Custom Inventory

    Posted Aug 05, 2015 10:59 AM

    Hi there, we are going to be doing a MS Office 2013 upgrade within our environment.  I have been asked to create a custom inventory to capture the MS Outlook Addins that are currently installed on the Win 7 workstations prior to the 2013 upgrade.

    I've been looking through the forums for something that I could reuse but can't seem to find anything and am having a  hard time trying to modify some of the samples. 

    Can anybody help me out?

    I need to capture the keys that exist under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\Outlook\Addins with the Description and FriendlyName for each of those subkeys.

    Ideally the results returned would indicate the machine name and then list the additional fields below.

    AddIn Name   :BCSAddin.Connect
    FriendlyName :Business Connectivity Services Add-In
    Description  :This Add-in is used by Business Connectivity Services.

     

     



  • 2.  RE: Custom Inventory

    Posted Aug 05, 2015 02:17 PM

    This article is an introduction for custom inventory, I think it should help you.



  • 3.  RE: Custom Inventory

    Posted Aug 06, 2015 02:48 PM

    Hi there, thanks for the response.

    I have everything setup and tested the powershell script above using a job, but I'm getting Failure Return Code - 1.

    I can't see anything in the log files and not sure how to troubleshoot the issue, any advice?



  • 4.  RE: Custom Inventory

    Posted Aug 06, 2015 03:30 PM

    did you remember to change the GUID in there to the GUID of your dataclass?

     

    though to be honest running this powershell script as a task works Ok in my Altiris I get succes exit code.

     

    perhaps a copy error on the script?



  • 5.  RE: Custom Inventory

    Posted Aug 06, 2015 04:38 PM
      |   view attached

    Yes, I did change the GUID, and recopied again into a task but still same error.

    I've attached a copy of the script I am using, from what I can tell it looks the same.

    This is the first time I am using a powershell script, any prereq's for the workstation?

    Attachment(s)

    txt
    OutlookAddins.txt   1 KB 1 version


  • 6.  RE: Custom Inventory

    Posted Aug 07, 2015 02:39 AM

    Have you configured the powershell execution policy on the workstation? 
    What does "Get-ExecutionPolicy" return if you run it manually on a workstation?



  • 7.  RE: Custom Inventory

    Posted Aug 07, 2015 09:35 AM

    Make the Dataclass and get its GUID

    The first thing that you have to do is create the custom data class that will house the data. Think of this as a table to house your data

    Settings> All settings

    Then Discovery and Inventory > Inventory Solution > Manage Custom Data classes

    Make a new Data class that contains the attributes "Columns" that you want to have in this table.

    When you have made it get the GUID by clicking on the hand icon and copying the GUID.

    Make your Custom Inventory Script

    I use powershell for this.  Assuming your dataclass has string attributes for AddinName, FriendlyName,Description it would look something like this

    NOTE: replace the xx GUID data class in the script with the GUID from your own custom dataclass

    <#
    
    
    
        Exit Codes:
            1 = Error creating NSE COM Object
            2 = Error reading the registry and/or creating the data block
            3 = Error sending the NSE to the NS
    
    
    
    #>
    
    try{
        $nse = New-Object -comobject "Altiris.AeXNSEvent"
        $nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
        $nse.Priority = 1
    
        # Create a new inventory data row to send to the NS
        $invDataClass = $nse.AddDataClass("{xxxxxxx-xxxx-xxx-xxx-xxxxx}") # YourDATACLASS
        $invDataBlock = $nse.AddDataBlock($invDataClass)
    }
    catch [System.Exception]{
        Write-Warning "Unable to create the Altiris Inv COM object. $($Error[0])"
        exit 1
    }
    
    try{
        $OutlookAddins = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Office\Outlook\Addins
    Foreach ($Addin in $OutlookAddins){
    $AddinName = $Addin.PSChildName
    $FriendlyName = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Office\Outlook\Addins\$AddinName").FriendlyName
    $Description = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Office\Outlook\Addins\$AddinName").Description
    
    
            # init the row data
            $invDataRow = $invDataBlock.AddRow()
            $invDataRow.SetField(0, [string]$AddinName)
            $invDataRow.SetField(1, [string]$FriendlyName)
            $invDataRow.SetField(1, [string]$Description)
      }  
    }
    catch [System.Exception]{
        Write-Warning "Unable to create the inventory data block. $($Error[0])"
        exit 2
    }
    
    try{
        # send the data to the NS
        $nse.SendQueued()
    }
    catch [System.Exception]{
        Write-Warning "Unable to send the inventory data block to the NS. $($Error[0])"
        exit 3
    }
    

    After that you would run the script againt the computers via Job or policy to gather your data.

     

    Note there is no need to gather the computer name as the GUID comes with the NSE as it is sent and is correlated to the computer record.

     



  • 8.  RE: Custom Inventory

    Posted Aug 07, 2015 11:27 AM

    Its set to restricted and I don't have access to change it to unrestricted.

    I guess I won't be able to use this, are you able to convert this into a vbscript?



  • 9.  RE: Custom Inventory

    Posted Aug 07, 2015 02:08 PM

    if you are an admin you should be able to set this to remote-signed by first running powershell as an admin.  Right click and choose "run as administrator"  on the powershell executable.

    Once that launches you can run  Set-ExecutionPolicy remotesigned

    you are going to want to be able to run powershell on your desktops in general.  Since it is way better than VBS for most things.

    Custom inventory will work with VBS as well the theory is the same. Looping through the subkeys would take a bit of work in a VBS that I am out of practice in.

    Here is some bits of code from an old custom inventory to get you started if your really need to go with VBS

    Basically imagine that above this block you are getting the values for variables using regular old vbs to search the reg.

    Here is the NSE block

    '===================================================================================================================
    '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 ("{YOURGUID}")
    dim objDataClass
    set objDataClass = nse.AddDataBlock (objDCInstance)
    'Add a new row
    dim objDataRow
    set objDataRow = objDataClass.AddRow
    
    'Set columns
    objDataRow.SetField 0, Name
    objDataRow.SetField 1, FriendlyName
    objDataRow.SetField 2, Description
    
    nse.SendQueued

     



  • 10.  RE: Custom Inventory

    Posted Aug 12, 2015 11:02 AM

    You personally might not have access to change to unrestricted, but there are sample tasks to do this already built into the SMP console.

    2015-08-12_9-54-45.png

     

     

    Since you will be running the task in the 'System' context, you can get around that whole "not having access" issue.

     

    Or...you could just encode your PowerShell script in Base64 and then call it from the command line. For example, here is script that basically searches through the registry and removes some entries that I dont like (old NS's that are throwing errors in my CEM gateway logs).

     

    This method will get around execution policy issues as well.

    2015-08-12_10-00-29.png



  • 11.  RE: Custom Inventory

    Posted Oct 04, 2023 06:40 PM
    Edited by WDRAIN1 Oct 04, 2023 06:43 PM

    I know this is an older post, but wanted share a custom inventory that we are using to upgrade Office to X64 that inventories all Microsoft Apps addins. It needs to be ran under the user context to retrieve the HKCU keys. I tweaked the powershell script logic from earlier post to retrieve registry keys that match addin from the Office registry path.

    sample output that is inventoried to the Altiris NS 

    Powershell Output
    <#
    Custom Inventory to retrieve MS Office addin/Plugin information from the registry
    #>
    
    FUNCTION REGKEY_UPDATE {
        PARAM ($REGKEY)
        SWITCH ( $REGKEY) {
         { $_ -MATCH '_USER' } { ($_).replace( "HKEY_CURRENT_USER\","HKCU:\" )  }
         { $_ -MATCH '_MACHINE' } { ($_).replace( "HKEY_LOCAL_MACHINE\","HKLM:\" )  }
    
        }
    }
    
    $Office_Bitness = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration' -ErrorAction SilentlyContinue).Platform
    $OS_Bitness = switch ($((Get-CimInstance Win32_operatingsystem).OSArchitecture)) { "64-Bit" {"x64"} "32-Bit" {"x86"} }
    $MSOFFICE_REGKEYS = @("HKLM:\Software\Microsoft\office","HKLM:\Software\Wow6432Node\Microsoft\Office","HKCU:\Software\Microsoft\office","HKCU:\Software\Wow6432Node\Microsoft\Office")
    
    # Retrives MS Office addins info from registry keys from the $MSOFFICE_REGKEYS variable
    $MSOFFICE_ADDINS = $MSOFFICE_REGKEYS | % {
        (GCI $_ -ErrorAction SilentlyContinue | SELECT NAME | % { 
           GCI  $(REGKEY_UPDATE $_.NAME) } | SELECT NAME | ? {
           $_.NAME -MATCH 'ADDINS'} | % { 
            GCI $(REGKEY_UPDATE $_.NAME) | % { 
                Get-ItemProperty (REGKEY_UPDATE $_.NAME)  } |
                SELECT @{N="Office App";E={ (($_.PSParentPath -split "Office")[1]) -replace "\\Addins","" -replace "\\","" }}, 
                    @{N="PluginName";E={ $_.FriendlyName }}, @{N="Plugin";e={$_.pschildname}} , Description,
                    @{N="Bitness";E={ $Office_Bitness }},  LoadBehavior,
                    @{N="Registry Path";E={ REGKEY_UPDATE (($_.PSParentPath -split "::")[1])  }}
            }
        )
    } 
    
    $MSOFFICE_ADDINS | ? { $_.LoadBehavior -NE $NULL } | FT 
    
    $nse = New-Object -comobject "Altiris.AeXNSEvent"
    $nse.To = "{1592B913-72F3-4C36-91D2-D4EDA21D2F96}"
    $nse.Priority = 1
    
    # Create a new inventory data row to send to the NS
    $invDataClass = $nse.AddDataClass("{6b763f2e-bffe-4703-ae83-6b7059411003}") ## REPLACE WITH Your DATACLASS
    $invDataBlock = $nse.AddDataBlock($invDataClass)
    
    $MSOFFICE_ADDINS | ? { $_.LoadBehavior -NE $NULL } | % {
        # init the row data
        $invDataRow = $invDataBlock.AddRow()
        $invDataRow.SetField(0, $_.PluginName)
        $invDataRow.SetField(1, $_.Plugin)
        $invDataRow.SetField(2, $_.Description)
        $invDataRow.SetField(3, $_.'Office App')
        $invDataRow.SetField(4, $_.Bitness)
        $invDataRow.SetField(5, $_.LoadBehavior)
        $invDataRow.SetField(6, $_.'Registry Path')
    }
    
    try{
        # send the data to the NS
        $nse.SendQueued()
    }
    catch [System.Exception]{
        Write-Warning "Unable to send the inventory data block to the NS. $($Error[0])"
        exit 3
    }