Working with DataNow 'LastSyncTime' Registry Value

Version 2

    Verified Product Versions

    AppSense DataNow 3.6AppSense DataNow 4.0AppSense DataNow 4.1

    Introduction

    DataNow maintains a record in the registry of the last time the current user synced with the DataNow appliance.

    This is found in the following location:

    Registry Key:  HKCU\Software\AppSense\DataNow
    Value Type:    REG_QWORD
    Value Name:    LastSyncTime
    Value Data:    <updated at each sync>

    The value is a 64 bit integer, representing the number of nanosecond increments since January 1, 1601 (FILETIME structure)

    This knowledge article provides an example of how this functionality could be leveraged by Environment Manager to perform age related actions

    Detail

    The following example script can be deployed as a post-desktop created custom PowerShell condition. The condition is satisfied when the last sync time breaches $days (as an example this is set to 7 days)

    An associated action could then be triggered to alert the user, alert the admin or generate audit information for reporting purposes.

     

    Start-Sleep -s 20

     

    $days = 7

     

    $key = 'HKCU:\SOFTWARE\AppSense\DataNow'

     

    $lastSyncTime = (Get-ItemProperty -path $key -name LastSyncTime).LastSyncTime

     

    $friendlyLocalSyncTime = [DateTime]::FromFileTime($lastSyncTime)

     

    $delta = New-TimeSpan –start $friendlyLocalSyncTime –end (Get-Date)

     

    if ($delta.TotalDays -ge $days) {

     

        exit (0)

     

    }

     

    else {

     

        exit (1)

     

    }

    As a further example, see the 'attachments' section below for an Environment Manager configuration snippet which leverages two conditions - the first condition is satisfied between 7 and 20 days, and will trigger a native windows systray popup notification warning the user, and generate a Windows event log entry. The second condition is satisfied when the cache hasn't been synced in 21 and above days, and triggers an 'error' popup and event log notification.

    It should be noted that whilst every effort has been made to ensure the accuracy and functionality of the sample code, it has not received official testing therefore the following disclaimer applies

     

    THE CODE CONTAINED WITHIN THIS SOLUTION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

    IMPORTANT: Please take care when executing any changes to your systems. We strongly recommend a full system backup is performed prior to use of the supplied code.

     

    Attachment

    Click the following hyperlink to download the Environment Manager policy snippet: See Attachment : DataNow_Sync_check snippet.xml (below)

    (exported from Environment Manager 8.6.313) This is applied by right-clicking a node under the 'Desktop Created' sub-trigger and selecting AppSense Policy Templates / Import Template.