<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: TA-Sysmon-deploy: Issue with deploy.bat in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/528902#M89134</link>
    <description>&lt;P&gt;that is correct. Both, config and installation must be there..&lt;BR /&gt;&lt;BR /&gt;about script and your environment, you can test it first on your windows station, when you confirm that work in both case (deploy and update), you can test it from splunk..&lt;/P&gt;&lt;P&gt;ofc. take care of path when you test it on system&lt;/P&gt;</description>
    <pubDate>Wed, 11 Nov 2020 00:35:27 GMT</pubDate>
    <dc:creator>vmicovic2</dc:creator>
    <dc:date>2020-11-11T00:35:27Z</dc:date>
    <item>
      <title>TA-Sysmon-deploy: Issue with deploy.bat</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/518918#M87741</link>
      <description>&lt;P&gt;I am attempting to use the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://splunkbase.splunk.com/app/3810/" target="_blank" rel="noopener nofollow noopener noreferrer"&gt;"TA-Sysmon-deploy"&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Splunkbase app to deploy and maintain Sysmon on our endpoints. I've noticed that the script which checks for sysmon then installs it does run correctly. It always results in a "sysmon not found" situation and re-installs it. This is expected activity if the script does not see sysmon running or it detects is out of date. Nonetheless, the script completes each time by installing sysmon again and again, even thought the host has the proper version of sysmon installed and running.&lt;/P&gt;&lt;P&gt;The peculiar thing here is that it works correctly if I run the batch script manually from an Admin (as system) command prompt but not when run by the Splunk Universal Forwarder. I've added an Echo statement so I can the check script variables just before they go into the deployment IF statements. Theyare correct when manually run but are not when executed by Splunk.&lt;/P&gt;&lt;P&gt;Any comments or suggestions would be helpful. I have included sample logs and the script below.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you,&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;sysmon.log when Splunk runs the batch file via input setting.&lt;/P&gt;&lt;P&gt;Thu 09/10/2020- 9:19:40.03 The SplunkUniversalForwarder is installed at C:\Program Files\SplunkUniversalForwarder&lt;BR /&gt;Thu 09/10/2020- 9:19:40.03 Checking for Sysmon&lt;BR /&gt;&lt;STRONG&gt;CHECK_SYSMON_VERSION=""&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CHECK_SYSMON_RUNNIG=""&lt;/STRONG&gt;&lt;BR /&gt;Thu 09/10/2020- 9:19:40.03 Sysmon not found, proceding to install&lt;BR /&gt;Thu 09/10/2020- 9:19:40.03 Copying the latest config file&lt;BR /&gt;0% copied&lt;BR /&gt;100% copied 1 file(s) copied.&lt;BR /&gt;Thu 09/10/2020- 9:19:40.03 Installing Sysmon&lt;BR /&gt;Thu 09/10/2020- 9:19:40.03 Install complete!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;sysmon.log when run from and Admin command prompt (as "system")&lt;/P&gt;&lt;P&gt;Wed 09/09/2020- 9:08:59.03 The SplunkUniversalForwarder is installed at C:\Program Files\SplunkUniversalForwarder&lt;BR /&gt;Wed 09/09/2020- 9:08:59.03 Checking for Sysmon&lt;BR /&gt;&lt;STRONG&gt;CHECK_SYSMON_RUNNIG="1"&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;CHECK_SYSMON_VERSION="1"&lt;/STRONG&gt;&lt;BR /&gt;Wed 09/09/2020- 9:08:59.03 Sysmon found, checking version&lt;BR /&gt;Wed 09/09/2020- 9:08:59.03 Sysmon already up to date, exiting&lt;/P&gt;&lt;P&gt;Here is the script from the deploy.bat file. This batch file is part of "TA-Sysmon-deploy" from Splunkbase. I have added the following to the script while troubleshooting.&lt;/P&gt;&lt;P&gt;- SETLOCAL and ENDLOCAL: removes any outside the script variable influences&lt;BR /&gt;- Enclosed the version check FOR statement in an IF EXIST clause, the script seemed to error out if sysmon.exe did not exist)&lt;BR /&gt;- added variable output "echo" statements so I can see the variable in the logs just before the IF statements.&lt;/P&gt;&lt;P&gt;TA's deploy.bat file&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ECHO OFF

SETLOCAL

FOR /F "delims=" %%i IN ('wmic service SplunkForwarder get Pathname ^| FINDSTR /m service') DO SET SPLUNKDPATH=%%i
SET SPLUNKPATH=%SPLUNKDPATH:~1,-28%

&amp;gt;&amp;gt; %WINDIR%\sysmon.log (
ECHO %DATE%-%TIME% The SplunkUniversalForwarder is installed at %SPLUNKPATH%
ECHO %DATE%-%TIME% Checking for Sysmon

FOR /F "delims=" %%c IN ('sc query "Sysmon" ^| FIND /c "RUNNING"') DO (
    SET CHECK_SYSMON_RUNNIG=%%c
)

IF EXIST %WINDIR%\sysmon.exe (
FOR /F "delims=" %%b IN ('c:\windows\sysmon.exe ^| FIND /c "System Monitor v11.11"') DO (
    SET CHECK_SYSMON_VERSION=%%b
)
)

ECHO CHECK_SYSMON_VERSION="%CHECK_SYSMON_VERSION%"
ECHO CHECK_SYSMON_RUNNIG="%CHECK_SYSMON_RUNNIG%"

if "%CHECK_SYSMON_RUNNIG%" == "1" (
    ECHO %DATE%-%TIME% Sysmon found, checking version
    IF "%CHECK_SYSMON_VERSION%" == "1" (
        ECHO %DATE%-%TIME% Sysmon already up to date, exiting
	ENDLOCAL
        EXIT
    ) ELSE (
        ECHO %DATE%-%TIME% Sysmon binary is outdated, un-installing
        IF EXIST %WINDIR%\sysmon.exe (
            %WINDIR%\sysmon.exe -u
        )
    )
) ELSE (
    ECHO %DATE%-%TIME% Sysmon not found, proceding to install
    ECHO %DATE%-%TIME% Copying the latest config file
    COPY /z /y "%SPLUNKPATH%\etc\apps\TA-Sysmon-deploy\bin\config.xml" "C:\windows\"
    ECHO %DATE%-%TIME% Installing Sysmon
    "%SPLUNKPATH%\etc\apps\TA-Sysmon-deploy\bin\sysmon.exe" /accepteula -i c:\windows\config.xml | Find /c "Sysmon installed" 1&amp;gt;NUL
    ECHO %DATE%-%TIME% Install complete!
    ENDLOCAL    
    EXIT
)
ECHO %DATE%-%TIME% Install failed
)
ENDLOCAL&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 10 Sep 2020 16:28:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/518918#M87741</guid>
      <dc:creator>kwasielewski</dc:creator>
      <dc:date>2020-09-10T16:28:23Z</dc:date>
    </item>
    <item>
      <title>Re: TA-Sysmon-deploy: Issue with deploy.bat</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/528753#M89115</link>
      <description>&lt;P&gt;hi, you must add sysmon installation in splunk app locally (from where splunk push installation to clients).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 23:32:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/528753#M89115</guid>
      <dc:creator>vmicovic2</dc:creator>
      <dc:date>2020-11-09T23:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: TA-Sysmon-deploy: Issue with deploy.bat</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/528876#M89132</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thank you for the reply.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The installation files are contained in the "TA-Sysmon-deploy"&amp;nbsp; app in the Splunk UF directory.&amp;nbsp; Is that correct or did I misunderstanding your comment?&amp;nbsp;&lt;/P&gt;&lt;P&gt;"%SPLUNKPATH%\etc\apps\&lt;STRONG&gt;TA-Sysmon-deploy\bin\sysmon.exe&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ken&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 19:32:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/528876#M89132</guid>
      <dc:creator>kwasielewski</dc:creator>
      <dc:date>2020-11-10T19:32:15Z</dc:date>
    </item>
    <item>
      <title>Re: TA-Sysmon-deploy: Issue with deploy.bat</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/528902#M89134</link>
      <description>&lt;P&gt;that is correct. Both, config and installation must be there..&lt;BR /&gt;&lt;BR /&gt;about script and your environment, you can test it first on your windows station, when you confirm that work in both case (deploy and update), you can test it from splunk..&lt;/P&gt;&lt;P&gt;ofc. take care of path when you test it on system&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 00:35:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/528902#M89134</guid>
      <dc:creator>vmicovic2</dc:creator>
      <dc:date>2020-11-11T00:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: TA-Sysmon-deploy: Issue with deploy.bat</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/534949#M89741</link>
      <description>&lt;P&gt;you should use&amp;nbsp;SETLOCAL ENABLEDELAYEDEXPANSION instead of&amp;nbsp;SETLOCAL and change your code to&amp;nbsp; this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;ECHO OFF&lt;/P&gt;&lt;P&gt;SETLOCAL ENABLEDELAYEDEXPANSION&lt;/P&gt;&lt;P&gt;FOR /F "delims=" %%i IN ('wmic service SplunkForwarder get Pathname ^| FINDSTR /m service') DO SET SPLUNKDPATH=%%i&lt;BR /&gt;SET SPLUNKPATH=%SPLUNKDPATH:~1,-28%&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt; %WINDIR%\sysmon.log (&lt;BR /&gt;ECHO %DATE%-%TIME% The SplunkUniversalForwarder is installed at %SPLUNKPATH%&lt;BR /&gt;ECHO %DATE%-%TIME% Checking for Sysmon&lt;/P&gt;&lt;P&gt;FOR /F "delims=" %%c IN ('sc query "Sysmon" ^| FIND /c "RUNNING"') DO (&lt;BR /&gt;SET CHECK_SYSMON_RUNNIG=%%c&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;IF EXIST %WINDIR%\sysmon.exe (&lt;BR /&gt;FOR /F "delims=" %%b IN ('c:\windows\sysmon.exe ^| FIND /c "System Monitor v11.11"') DO (&lt;BR /&gt;SET CHECK_SYSMON_VERSION=%%b&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;ECHO CHECK_SYSMON_VERSION=!CHECK_SYSMON_VERSION!&lt;BR /&gt;ECHO CHECK_SYSMON_RUNNIG=!CHECK_SYSMON_RUNNIG!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if "!CHECK_SYSMON_RUNNIG!" == "1" (&lt;BR /&gt;ECHO %DATE%-%TIME% Sysmon found, checking version&lt;BR /&gt;IF "!CHECK_SYSMON_VERSION!" == "1" (&lt;BR /&gt;ECHO %DATE%-%TIME% Sysmon already up to date, exiting&lt;BR /&gt;ENDLOCAL&lt;BR /&gt;EXIT&lt;BR /&gt;) ELSE (&lt;BR /&gt;ECHO %DATE%-%TIME% Sysmon binary is outdated, un-installing&lt;BR /&gt;IF EXIST %WINDIR%\sysmon.exe (&lt;BR /&gt;%WINDIR%\sysmon.exe -u&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;) ELSE (&lt;BR /&gt;ECHO %DATE%-%TIME% Sysmon not found, proceding to install&lt;BR /&gt;ECHO %DATE%-%TIME% Copying the latest config file&lt;BR /&gt;COPY /z /y "%SPLUNKPATH%\etc\apps\TA-Sysmon-deploy\bin\config.xml" "C:\windows\"&lt;BR /&gt;ECHO %DATE%-%TIME% Installing Sysmon&lt;BR /&gt;"%SPLUNKPATH%\etc\apps\TA-Sysmon-deploy\bin\sysmon.exe" /accepteula -i c:\windows\config.xml | Find /c "Sysmon installed" 1&amp;gt;NUL&lt;BR /&gt;ECHO %DATE%-%TIME% Install complete!&lt;BR /&gt;ENDLOCAL&lt;BR /&gt;EXIT&lt;BR /&gt;)&lt;BR /&gt;ECHO %DATE%-%TIME% Install failed&lt;BR /&gt;)&lt;BR /&gt;ENDLOCAL&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2021 13:05:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/TA-Sysmon-deploy-Issue-with-deploy-bat/m-p/534949#M89741</guid>
      <dc:creator>ali-tavakoli</dc:creator>
      <dc:date>2021-01-06T13:05:06Z</dc:date>
    </item>
  </channel>
</rss>

