Skip to content

Autofix Broken Agents

Gavin Stone edited this page Jul 8, 2020 · 9 revisions

Warning - Some of the commands below can Impact your agents so proceed with care

Please note - to run these tasks successfully your agents need to be able to access the URL https://raw.githubusercontent.com/LabtechConsulting/LabTech-Powershell-Module/master/LabTech.psm1 - if you have problems you may need to whitelist this URL

Start with this

Get-AutomateComputer -Online $False | Compare-AutomateControlStatus which will give you a list of Computers that are online in Control and Offline in Automate. You can also run Compare-AutomateControlStatus on its own which will check all machines in Automate. If you want to return every session comparison between Automate and Control, you can do $Object = Compare-AutomateControlStatus -AllResults

Then Autofix (start with Restart service)

Get-AutomateComputer -Online $False | Compare-AutomateControlStatus | Repair-AutomateAgent -Action Restart

If that doesn't work, try an agent update

Get-AutomateComputer -Online $False | Compare-AutomateControlStatus | Repair-AutomateAgent -Action Update

If it is still broken, do a reinstall

Get-AutomateComputer -Online $False | Compare-AutomateControlStatus | Repair-AutomateAgent -Action Reinstall

What does this do?

In basic terms it gets a list of computers, checks their status versus the equivalent status in control, then initialises commands using https://github.com/LabtechConsulting/LabTech-Powershell-Module to either restart services or reinstall an agent. It then returns an object of the results.

What Actions do I have?

Available at present are Update, Restart, ReInstall and Check.

Check runs: (new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Get-LTServiceInfo

Update runs: (new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Update-LTService

Restart runs: (new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; Restart-LTService

Reinstall runs: (new-object Net.WebClient).DownloadString('http://bit.ly/LTPoSh') | iex; ReInstall-LTService

What if I want to miss a few agents

In the commands above you will be prompted for each agent it finds and you can press y or n to process them

What if I want to run them all and not get prompted?

Add -Confirm:$false to the parameters on Repair-AutomateAgent