Comments (2)
I will post my modified script which works for me. Hope it will be help for somebody.
ECHO OFF
FOR /F "delims=" %%i IN ('wmic service SplunkForwarder get Pathname ^| FINDSTR /m service') DO SET SPLUNKDPATH=%%i
SET SPLUNKPATH=%SPLUNKDPATH:~1,-28%
>> %WINDIR%\sysmon.log (
setlocal EnableDelayedExpansion
ECHO %DATE%-%TIME% "deploy.bat" Checking for Sysmon status
FOR /F "delims=" %%c IN ('sc query "Sysmon" ^| FIND /c "RUNNING"') DO (
SET CHECK_SYSMON_RUNNIG=%%c
)
FOR /F "delims=" %%b IN ('c:\windows\sysmon.exe ^| FIND /c "System Monitor v13.01"') DO (
SET CHECK_SYSMON_VERSION=%%b
)
if "!CHECK_SYSMON_RUNNIG!" == "1" (
ECHO %DATE%-%TIME% Sysmon found, checking if it is version v13.01
IF "!CHECK_SYSMON_VERSION!" == "1" (
ECHO %DATE%-%TIME% Sysmon already up to date, exiting
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 and install file
COPY /z /y "%SPLUNKPATH%\etc\apps\TA-Sysmon-deploy\bin\config.xml" "C:\windows\"
COPY /z /y "%SPLUNKPATH%\etc\apps\TA-Sysmon-deploy\bin\sysmon.exe" "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>NUL
ECHO %DATE%-%TIME% Install complete!
powershell -Command "& {Restart-Service Splunkforwarder;}"
EXIT
)
ECHO %DATE%-%TIME% Install failed
)
from ta-sysmon-deploy.
I will post my modified script which works for me. Hope it will be help for somebody.
ECHO OFF FOR /F "delims=" %%i IN ('wmic service SplunkForwarder get Pathname ^| FINDSTR /m service') DO SET SPLUNKDPATH=%%i SET SPLUNKPATH=%SPLUNKDPATH:~1,-28% >> %WINDIR%\sysmon.log ( setlocal EnableDelayedExpansion ECHO %DATE%-%TIME% "deploy.bat" Checking for Sysmon status FOR /F "delims=" %%c IN ('sc query "Sysmon" ^| FIND /c "RUNNING"') DO ( SET CHECK_SYSMON_RUNNIG=%%c ) FOR /F "delims=" %%b IN ('c:\windows\sysmon.exe ^| FIND /c "System Monitor v13.01"') DO ( SET CHECK_SYSMON_VERSION=%%b ) if "!CHECK_SYSMON_RUNNIG!" == "1" ( ECHO %DATE%-%TIME% Sysmon found, checking if it is version v13.01 IF "!CHECK_SYSMON_VERSION!" == "1" ( ECHO %DATE%-%TIME% Sysmon already up to date, exiting 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 and install file COPY /z /y "%SPLUNKPATH%\etc\apps\TA-Sysmon-deploy\bin\config.xml" "C:\windows\" COPY /z /y "%SPLUNKPATH%\etc\apps\TA-Sysmon-deploy\bin\sysmon.exe" "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>NUL ECHO %DATE%-%TIME% Install complete! powershell -Command "& {Restart-Service Splunkforwarder;}" EXIT ) ECHO %DATE%-%TIME% Install failed )
Doh, found this too late.
I ended up just adding two blocks of >> %WINDIR%\sysmon.log () in the script ensuring the FOR statements were not included in them.
from ta-sysmon-deploy.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ta-sysmon-deploy.