When Kace agents become unresponsive, due to eg hibernation of the laptop are broken configuration it needs to be uninstalled.

 

Here is a tool to silently uninstall agents from multiple computers at once over the network with no user notifications or user interaction.
The computers need to be connected to the network.

 

The script uses the PSexec util found on https://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, complete with full interactivity for console applications, without having to manually install client software. PsExec's most powerful uses include launching interactive command-prompts on remote systems and remote-enabling tools like IpConfig that otherwise do not have the ability to show information about remote systems.

Note: some anti-virus scanners report that one or more of the tools are infected with a "remote admin" virus. None of the PsTools contain viruses, but they have been used by viruses, which is why they trigger virus notifications.

Installation: Save PsExec to a folder of your choice.  For me it's c:\temp Just be sure to adjust the command accordingly if you place PSexec somewhere else.
note: Typing "psexec" displays its usage syntax.

 

Script requisites

1. Computer list
create a text file called computerlist.txt, and type all computer names needing the Kace agent removal in there.  Should you want to use IP addresses instead of machine names, that is no problem  

save this file in the same location as your PSexec.exe file

2. Removal script
create a bat file called ampuninstall.bat and add the following 2 lines      

cd C:\Program Files\dell\kace
AMPTools uninstall all
 

save this batch file in the same location as your PSexec.exe file and the computerlist.txt
 

IMPORTANT - this is for x86 computers
in case of x64 computers be sure to change the program files folder location

cd C:\Program Files (x86)\dell\kace
AMPTools uninstall all
 

save this batch file in the same location as your PSexec.exe file and the computerlist.txt

 

note: see https://support.software.dell.com/k1000-systems-management-appliance/kb/146458 for more AMPTools command switches


3. Script

for /f %G in ('type "c:\temp\computerlist.txt"') do psexec \\%G -s -c -accepteula ampuninstall.bat

 

run the script by opening a command prompt and browse to your folder where PSexec is placed into - for me it's c:\temp.
should you use a different location, be sure to to adjust the command accordingly. 
 

explanation of the script

-s = run as local system
-c = copy file (ampuninstall.bat) over to client and then execute
-accepteula = not to show the popup to accept the use of PSexec


Essentially what this command does is sets a variable for the machine name, and for every line in the computerlist.txt file, replaces that variable (%G) with the target IP or hostname you want to connect to.
Whenever the script can't connect to a computer it will skip and move on to the next one in the list

 

Sources - combination of these 2 Kace KB's and a lot of sweat and testing
https://support.software.dell.com/k1000-systems-management-appliance/kb/146458
https://support.software.dell.com/kb/127898    

 

Agent reinstallation

Once successfully removed, the Kace agent will reinstall itself from GPO.