VBScript to check LANDesk Agent Health and reinstall if needed

Version 6

    Verified Product Versions

    Endpoint Manager 9.5



    The following LANDesk Health Check VBScript will check various components of the LANDesk 8.8 and 9.0 Agent, and if any of the checks fail, will reinstall an Advance Agent.  It will also send an email when a check fails with the log of the failure.


    The script is designed to be used in conjunction with an Active Directory Group Policy that runs the script as a Startup script.  This will run with rights from LocalSystem which will get around any issues with UAC or limited user rights.


    The script attempts to map a LANDesk Agent Configuration with an Active Directory OU, and can associate different agents with different OU's.  If a mapping can not be made then the default agent is installed.


    The script will determine what AD OU the machine is in, check the registry for the core server that it is contacting and check the registry for the agent name that is installed.  It will also check that the certificate file for the core server is present on the machine.  If the OU, Core and Agent don't match with the mapping configured in the script, or if the certificate is incorrect, the Agent will be reinstalled using an Advance Agent.
    The script requires that each LANDesk Agent listed in the mapping section have an advance agent already created and configured on the LANDesk Core Server.



    The following items can be configured in the Agent Health Check VBScript:


    LANDesk Executables in LDClient folder - If the files are renamed or missing the Health Check fails and the Agent is reinstalled


    Local Scheduler Tasks - If the output for the local scheduler is missing the File names that should exist in Local Scheduler output, the Health Check fails and the Agent is reinstalled.


    LANDesk Services - The script will check for the existence of LANDesk services.  If any are stopped, the script will attempt to start the service.  If the script is unable to start any of the services the Health Check will fail and the Agent will be reinstalled.


    Email Notification - On script failure, an email is sent to the configured addresses with the log file in the body of the email that shows the reason for the Health Check failure.  The email is sent using the existing MAPI installation on the client.


    Log location - By default the script creates an LDMSAgentCheck.log file in the %TEMP% folder.  The Advance Agent also creates a LDinstall.log in %TEMP%. The script will also update the Registry in a configured location to add the information to the LDAPPL3 template if desired.


    Agent Mapping to Active Directory OU - The script allows mapping between different agents to Active Directory OU's and checks the .0 Certificate file.  If the .0 file is corrupted or missing, the Health Check will fail.  If the Agent Mapping fails to match any OU's, then the default agent install will be used.


    LDMSAgentHealthCheck_SQL.zip  Contains updates to the script provided by Shatterstorm. Most notably code cleanup and abiltiy to store Health Check logs in db instead of sending an e-mail.