Secure Agent repository management examples


The NTsecure1.bat and NTsecure2.bat files illustrate how you can manage a data repository on remote secure computers. The scripts list the seven latest collected data repositories for each computer and instance combination. You can schedule these scripts a few minutes after the data collection start script.

NTsecure1.bat

The NTsecure1.bat script provides the seven latest data directories for each instance.

REM This script will keep 7 latest data directories
REM for each instance
echo off
set KEEP_7="skip=7"
REM The Destination Repository must be specified in
this script
REM Hardwire the repository
set DESTINATION_REPOSITORY=D:\<DestinationRepos>
REM Get a directory listing of the Destination
Repository
REM and only list directory names
FOR /F %%n IN ('dir /B /O-D /AD
%DESTINATION_REPOSITORY%')
DO (@echo %%n
FOR /F %%i IN ('dir /B /O-D /AD
%DESTINATION_REPOSITORY%&#92;%%n')
DO(@echo %%i
FOR /F %KEEP_7% %%d IN ('dir /B /O-D
/AD %DESTINATION_REPOSITORY%\%%n\%%i')
DO (@echo rmdir /S /Q %%d )

NTsecure2.bat

The NTsecure2.bat script provides the most recent history for each node and instance.

REM This script finds the latest data for each
computer
REM and instance of collected data.
echo off
REM The Destination Repository must be specified in
this script
REM Hardwire the repository
set DESTINATION_REPOSITORY=D:\DestinationRepository
REM Get a directory listing of the Destination Repository
REM and only list directory names
FOR /F %%n IN ('dir /B /O-D /AD
%DESTINATION_REPOSITORY%')
DO (echo %%n
FOR /F %%i IN ('dir /B /O-D /AD
%DESTINATION_REPOSITORY%&#92;%%n')
DO(echo %%i
REM SORT by DATE with the latest being last
FOR /F %%d IN ('dir /B /O /AD
%DESTINATION_REPOSITORY%\%%n\%%i') DO (
REM CREATE temporary batch program
echo %%d
echo your command here %%n\%%i\%%d
newnode::newlocation >
%DESTINATION_REPOSITORY%\%%n\%%i\t.bat
)
)
)
REM CALL the Generated batch programs
FOR /F %%n IN ('dir /B /O-D /AD
%DESTINATION_REPOSITORY%')
DO (
FOR /F %%i IN ('dir /B /O-D /AD
%DESTINATION_REPOSITORY%\%%n')
DO(
call %DESTINATION_REPOSITORY%\%%n\%%i\t.bat
del %DESTINATION_REPOSITORY%\%%n\%%i\t.bat
)
)

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*