/bundles/itninjaweb/img/Breadcrumb_cap_w.png
I wrote a batch file.. not executed as a KACE script to look at a listing of hostnames that I know to have versions of the KACE agents prior to version 8.0. I'm using PSTools with it. It is suppoed to check the old Dell directories and the Quest directory for the existence of runkbot.exe and uninstall the KACE agent if it is there and copy the latest agent to the host and install the 8.0.152 version of the agent, and finally force the workstation to check in to the K1000. 

Batch file:

@ECHO OFF
Set PSExecDir=E:\pstools
Set InputFile=E:\scripts\badagent3.txt
Set OutputFile=C:\ScriptLogs\KACEAgentFix.txt
Set ErrorFile=C:\ScriptLogs\KaceError.txt

for /f %%a in (%InputFile%) do (

echo *** Checking Workstation %%a *** >> %OutputFile%

IF EXIST \\%%a\Progra~1\Dell\KACE\runkbot.exe GOTO DELL32
IF EXIST \\%%a\Progra~2\Dell\KACE\runkbot.exe GOTO DELL64
IF EXIST \\%%a\Progra~1\Quest\KACE\runkbot.exe GOTO QUEST32
IF EXIST \\%%a\Progra~2\Quest\KACE\runkbot.exe GOTO QUEST64

IF ERRORLEVEL 1 (echo There is a problem on %%a >> %ErrorFile%)
)

:DELL32
echo C:\Progra~1\Dell\KACE DETECTED!
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Dell\KACE"
%PSExecDir%\psexec \\%%a AmpTools.exe uninstall all-kuid
robocopy "E:\Scripts\AmpAgent" "\\%%a\C$\Temp"
ECHO ==== Installing KACE AMP Agent 8.0 ====
%PSExecDir%\psexec \\%%a msiexec.exe /i "C:\Temp\ampagent-8.0.152-x86_172.24.102.148.msi" /qn >> %OutputFile%
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
GOTO end

:DELL64
echo C:\Progra~2\Dell\KACE DETECTED!
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Dell\KACE"
%PSExecDir%\psexec \\%%a AmpTools.exe uninstall all-kuid
robocopy "E:\Scripts\AmpAgent" "\\%%a\C$\Temp"
ECHO ==== Installing KACE AMP Agent 8.0 ====
%PSExecDir%\psexec \\%%a msiexec.exe /i "C:\Temp\ampagent-8.0.152-x86_172.24.102.148.msi" /qn >> %OutputFile%
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
GOTO END

:QUEST32
echo C:\Progra~1\Quest\KACE DETECTED!
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Program Files\Quest\KACE"
%PSExecDir%\psexec \\%%a AmpTools.exe uninstall all-kuid
robocopy "E:\Scripts\AmpAgent" "\\%%a\C$\Temp"
ECHO ==== Installing KACE AMP Agent 8.0 ====
%PSExecDir%\psexec \\%%a msiexec.exe /i "C:\Temp\ampagent-8.0.152-x86_172.24.102.148.msi" /qn >> %OutputFile%
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
GOTO END

:QUEST64
echo C:\Progra~2\Quest\KACE DETECTED!
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a AmpTools.exe uninstall all-kuid
robocopy "E:\Scripts\AmpAgent" "\\%%a\C$\Temp"
ECHO ==== Installing KACE AMP Agent 8.0 ====
%PSExecDir%\psexec \\%%a msiexec.exe /i "C:\Temp\ampagent-8.0.152-x86_172.24.102.148.msi" /qn >> %OutputFile%
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~2\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
%PSExecDir%\psexec \\%%a -s CMD /C CD /D "C:\Progra~1\Quest\KACE"
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 4 0
%PSExecDir%\psexec \\%%a -s CMD /C runkbot.exe 6 0
GOTO END




:END


Here is the batch file output:


E:\scripts>kace_agent_fix.bat
C:\Progra~1\Dell\KACE DETECTED!

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

Couldn't access %a:
The network path was not found.

Make sure that the default admin$ share is enabled on %a.

PsExec v2.11 - Execute processes remotely
Copyright (C) 2001-2014 Mark Russinovich
Sysinternals - www.sysinternals.com

Couldn't access %a:
The network path was not found.

Make sure that the default admin$ share is enabled on %a.

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows                             
-------------------------------------------------------------------------------

  Started : Tuesday, June 12, 2018 2:49:47 PM
2018/06/12 14:49:47 ERROR 53 (0x00000035) Getting File System Type of Destination \\%a\C$\Temp\
The network path was not found.

   Source : E:\Scripts\AmpAgent\
     Dest - \\%a\C$\Temp\

    Files : *.*

  Options : *.* /DCOPY:DA /COPY:DAT /R:1000000 /W:30

------------------------------------------------------------------------------

2018/06/12 14:49:47 ERROR 53 (0x00000035) Accessing Destination Directory \\%a\C$\Temp\
The network path was not found.
Waiting 30 seconds...^CTerminate batch job (Y/N)? y

E:\scripts>

I killed the batch file as it got stuck waiting. I can easily connect to the first PC in the list, ping it, connect to its admin share etc.  

Can anyone help me out here? 

0 Comments   [ - ] Hide Comments

Comments

Please log in to comment

Answer this question or Comment on this question for clarity

Answers

0
So many questions, is there a reason why you just didn't allow the KACE box to manage your upgrade? I am guessing at what the issue is, we face a similar challenge when upgrading customers from say 6.4 to 8.x, it becomes difficult to upgrade the agent alongside as that will take time using the KACE agent upgrade functionality. We came up with this, we create a script to uninstall the agent, that looks at the varieties ii.e. Dell/Quest and runs the uninstallation, usually for a week before we upgrade. This in effect orphans every device that is connected. We then setup a new GPO to install the 8.x agent, so once the upgrade of the box is complete, as machines connect, they get the new agent.

This logic could also be applied to the removal of the agent if the GPO's are configured in the correct way.

I also know this isn't an Answer but it was way too long to stick in the Comments area ;o)
Answered 06/13/2018 by: Hobbsy
Red Belt

  • #1 - We have some bad agents in our environment and was told by Quest to remove them, hampering performance of the K1000.
    #2 - GPO does the initial agent install on fresh PCs

    We are basically trying to perform a clean up, as there are over almost 400 hosts that are out of regulation.
Please log in to comment
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share