How to Detect and Report Microsoft Outlook Cache Mode Status Using Custom Inventory
search cancel

How to Detect and Report Microsoft Outlook Cache Mode Status Using Custom Inventory

book

Article ID: 178548

calendar_today

Updated On:

Products

Inventory Solution

Issue/Introduction

 How to report if Microsoft Outlook Cache Mode Status Using Custom Inventory is used?

Environment

ITMS 8.x

Inventory Solution 8.x

Resolution

Custom inventory can be used to detect the cache mode status on computers by querying registry keys. The Custom Inventory script presented here was adapted from http://www.symantec.com/connect/downloads/get-outlook-cache-mode-status-custom-inventory to be able to detect cache mode for Microsoft Outlook 2007, 2010 and 2013. In addition this article presents a 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.

  1. Create a new custom Data Class that will store the Cache Mode status for each computer.
    1. Go to Settings>All Settings then Settings>Discovery and Inventory>Inventory Solution>Manage Custom Data Classes.
    2. Click New data class.
    3. Name the Data Class "Outlook Cache Mode" and click OK.
    4. Click Add attribute.
    5. Name the Attribute "User Name", set Key to "No", and click OK.
    6. Add two more attributes the same way, naming them Profile and then Cache Mode.
    7. Enable Allow multiple rows from a single computer resource, then click Save changes. The final dataclass should look like figure 1.

    Figure 1. Configuration for the Custom Data Class and its Attributes
     
  2. Create a Custom Inventory Script Task.
    1. Go to Manage>Jobs and Tasks.
    2. Browse the folder drop-down menu to where you would like to add a custom inventory script task.
    3. Right Click on the folder, then select New>Task.
    4. Select the Run Script task.
    5. Name the task appropriately.
    6. Select Script type: VBScript.
    7. Copy and paste the entire vbscript below into the large text box of the script task. 

      '*** Altiris NSE section
      '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. The following data class with below guid is already configured on server.
      dim objDCInstance
      set objDCInstance = nse.AddDataClass ("Outlook Cache Mode")
      'If the dataclass name does not work then use its guid (will be different in each environment)
      'set objDCInstance = nse.AddDataClass ("{0543bf90-028e-4dca-9e0e-c2239cfa35d1}")

      dim objDataClass
      set objDataClass = nse.AddDataBlock (objDCInstance)

      dim objDataRow

      '*** Custom Inventory section
      Const HKEY_USERS = &H80000003
      Const HKEY_CURRENT_USER = &H80000001 'HKEY_CURRENT_USER
      Set oReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
      'Pull all profiles from HKEY_USERS registry
      oReg.EnumKey HKEY_USERS, "", arrSubProfKeys

      'Check for Outlook 2013
      If oReg.EnumKey(HKEY_CURRENT_USER, "Software\Microsoft\office\15.0\Outlook\profiles\outlook", arrSubKeys) = 0 Then
       'Pull profile keys from each profile found
       For Each oSubProfKey in arrSubProfKeys

        strKeyPath2013a = oSubProfKey & "\Software\Microsoft\office\15.0\Outlook\profiles\outlook"
        oReg.EnumKey HKEY_USERS, strKeyPath2013a, arrSubKeys1

        On Error Resume Next
        For Each oSubKey1 In arrSubKeys1
         strFullKeyPath2013 = strKeyPath2013a & "\" & oSubKey1

         oReg.GetBinaryValue HKEY_USERS, strFullKeyPath2013, "00036601", sValue
         strCacheStatus = Join(sValue)

         If strCacheStatus <> "" Then
          Select Case strCacheStatus
           Case "4 16 0 0", "6 16 0 0" 'The off code 4 10 0 0 gets distorted by the string conversion
           strCacheMode = "Off"
           Case Else
           strCacheMode = "On"
          End Select
          oReg.GetStringValue HKEY_USERS, strFullKeyPath2013, "001e6603", cnUserName
          ArrUserName = Split(cnUserName, "=")
          strUserName = ArrUserName(4)
          oReg.GetStringValue HKEY_USERS, strFullKeyPath2013, "001e6750", strProfile

          'Add a new row to the NSE file
          set objDataRow = objDataClass.AddRow
          'Set columns
          objDataRow.SetField 0, strUserName
          objDataRow.SetField 1, strProfile
          objDataRow.SetField 2, strCacheMode
         End If

        strCacheStatus = ""
        Next
       Next

      Else
       'Loop for older versions of Outlook
       'Pull profile keys from each profile found
       For Each oSubProfKey in arrSubProfKeys
        strKeyPath1 = oSubProfKey & "\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
        oReg.EnumKey HKEY_USERS, strKeyPath1, arrSubKeys1

        On Error Resume Next
        For Each oSubKey1 In arrSubKeys1
         strKeyPath2 = strKeyPath1 & "\" & oSubKey1
         oReg.EnumKey HKEY_USERS, strKeyPath2, arrSubKeys2

         For Each oSubKey2 In arrSubKeys2
          strFullKeyPath = strKeyPath2 & "\" & oSubKey2
          'Retrieve Cache Mode, User name, and Outlook Profile Name key
          oReg.GetBinaryValue HKEY_USERS, strFullKeyPath, "00036601", sValue
          strCacheStatus = Join(sValue)

          If strCacheStatus <> "" Then
           Select Case strCacheStatus
            Case "4 0 0 0", " 4 0 0 0", "4 16 0 0"
            strCacheMode = "Off"
            Case Else
            strCacheMode = "On"
           End Select
           oReg.GetStringValue HKEY_USERS, strFullKeyPath, "001e6603", cnUserName
           ArrUserName = Split(cnUserName, "=")
           strUserName = ArrUserName(4)
           oReg.GetStringValue HKEY_USERS, strFullKeyPath, "001e6750", strProfile

           'Add a new row to the NSE file
           set objDataRow = objDataClass.AddRow
           'Set columns
           objDataRow.SetField 0, strUserName
           objDataRow.SetField 1, strProfile
           objDataRow.SetField 2, strCacheMode
          End If

          strCacheStatus = ""
         Next
        Next
       Next
      End If


      ' Send the NSE file to the NS server
      nse.SendQueued

       
    8. Check that the script task configuration looks like figure 2 and then click OK.

    Figure 2. Configuration for the Custom Inventory Script Task
     
  3. Run the Custom Inventory Script task on computers that have Microsoft Outlook.
    1. Click on New Schedule, choose Now or specify a schedule time and repeat interval.
    2. Specify target computers to run the task on.
      • To target a single computer click in the Quick add: box and search for the name of the computer, or use the Quick Run feature instead of New Schedule.
      • To target a list of computers click on Add>Computers or Devices then manually select the desired computers and click > and OK
      • To target a computer filter (such as All Computers) click on Add>Target, click Add rule, choose exclude computers not in, and search the name of the filter in the final drop-down box. then click OK.
  4. Create a Custom Report to view the data collected by the Custom Inventory
    1. Go to Reports>All Reports.
    2. Browse to a folder where you would like to add the custom report and Right Click on the folder.
    3. Select New>Report>SQL Report.
    4. Give the Report an appropriate name and then replace the text under Parameterized Query with the following query:

      select vComputer.Name [Computer], iOCM.[User Name], iOCM.[Profile], iOCM.[Cache Mode] from Inv_Outlook_Cache_Mode iOCM
      left join vComputer on vComputer.Guid = iOCM._ResourceGuid

    5. Click Save Changes and then view the collected custom inventory data for each computer.