Aims to check the LabTech agent on a Windows 7+ machine seems operable and re/install if required using specified LT server and location ID.
Designed so it can be directly called from a scheuled task (possibly created by Group Policy).
Written in Powershell for simplicity. Aims to provide compatability from Windows 7 - 10 (Server 2008 - 2019), but testing has been limited so please report any issues.
I welcome improvments to this code, please submit as pull requests or if you can't do that, post details of problem and fix as an Issue.
This code accepts you setting some variables before execution
$LTSrv = 'labtech.mymspname.here' # FQDN of your LabTech server (required - unless you modify script header)
$InstallerToken = '6f79953b88f8379bb8c96b4fe5ca151f' # See https://www.mspgeek.com/topic/5881-agent-deploy-generate-installers-with-tokens/ or you can pull this from the end of the Custom MSI download URL BUT unless you modify the DB the URL one will only work for 24 hours. (required)
$LTLoc = 1 # LabTech Location ID to add agent to (optional - defaults to 1)
$LogFile = '$Env:temp\Check-LTAgent-log.txt' # If you want a logfile, where do you want the file. (optional)
$LTSrv = 'labtech.mymspname.here' ; $InstallerToken = '6f79953b88f8379bb8c96b4fe5ca151f'; $LTLoc = 1 ; (new-object Net.WebClient).DownloadString('https://raw.githubusercontent.com/AlexHeylin/Check-LTAgent/master/Check-LTAgent.ps1') | iex ;
or in short form (if the Bitly stays live)
$LTSrv='labtech.mymspname.here';$InstallerToken='6f79953b88f8379bb8c96b4fe5ca151f';$LTLoc=1;(new-object Net.WebClient).DownloadString('https://bit.ly/2qO49e8')|iex;
Watch your quote types " vs ' when calling this directly from CMD.
Might need to use this on older versions - need to check compatability
$LTSrv='labtech.mymspname.here';$InstallerToken='6f79953b88f8379bb8c96b4fe5ca151f';$LTLoc=1;(new-object System.IO.StreamReader((([System.Net.WebRequest]::Create('https://bit.ly/2qO49e8')).GetResponse()).GetResponseStream())).ReadToEnd()|iex;