Repository navigation
Expand file tree
/
Copy pathmodule_system_sessions.cmd
More file actions
109 lines (89 loc) · 3.81 KB
/
Copy pathmodule_system_sessions.cmd
File metadata and controls
109 lines (89 loc) · 3.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
:: NAME: module_system_sessions
::#############################################################################
:: #DESCRIPTION#
:: module_system_sessions is intended to capture user session information.
::
::#############################################################################
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Author: David Geeraerts
:: Location: Olympia, Washington USA
:: E-Mail: dgeeraerts.evergreen@gmail.com
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Copyleft License(s)
:: GNU GPL (General Public License)
:: https://www.gnu.org/licenses/gpl-3.0.en.html
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::
:: VERSIONING INFORMATION ::
:: Semantic Versioning used ::
:: http://semver.org/ ::
:: Major.Minor.Revision ::
::::::::::::::::::::::::::::::::::
@Echo off
@SETLOCAL enableextensions
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
SET Name=module_system_sessions
SET Version=1.0.1
SET BUILD=20210119-0715
Title %Name% Version: %Version%
Prompt mss$G
color 8F
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::#############################################################################
:: Declare Global variables
:: All User variables are set within here.
::#############################################################################
:: Logging
:: Defaults
:: uses Public folder
SET "$LogPath=%PROGRAMDATA%\TESC\modules"
SET $Log=module_system_sessions_%COMPUTERNAME%.log
SET $LOG_ARCHIVE=module_system_sessions_%COMPUTERNAME%_archive.log
SET $LOG_AGGREGATED=module_system_sessions_aggregated.log
:: Log Server
SET $LOG_SERVER=SC-Vanadium
SET $LOG_SERVER_SHARE=Logs\module_system_sessions
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::##### Everything below here is 'hard-coded' [DO NOT MODIFY] #####
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: PARAMETERS
:: Passed in parameters (variables)
:: Overides defaults
SET $PARAMETER_1=%~1
SET $PARAMETER_2=%~2
IF DEFINED $PARAMETER_1 SET "$LogPath=%$PARAMETER_1%"
IF DEFINED $PARAMETER_2 SET "$Log=%$PARAMETER_2%"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Temp and Workspace setup
IF NOT EXIST "%$LogPath%" mkdir "%$LogPath%"
IF NOT EXIST "%$LogPath%\var" mkdir "%$LogPath%\var"
:: Archive existing log
IF EXIST "%$LogPath%\%$Log%" TYPE "%$LogPath%\%$Log%" >> "%$LogPath%\%$LOG_ARCHIVE%"
:: Get ISO-Date
@powershell Get-Date -format "yyyy-MM-dd" > "%$LogPath%\var\var_ISO8601_Date.txt"
SET /P $ISO_DATE= < "%$LogPath%\var\var_ISO8601_Date.txt"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:start
echo Start %$ISO_DATE% %TIME% > "%$LogPath%\%$Log%"
echo Computer: %COMPUTERNAME% >> "%$LogPath%\%$Log%"
echo Administrator: %USERNAME% >> "%$LogPath%\%$Log%"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:exec
:: Main Execution
query user >> "%$LogPath%\%$Log%"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:close
echo End %$ISO_DATE% %TIME% >> "%$LogPath%\%$Log%"
echo. >> "%$LogPath%\%$Log%"
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:ship
:: Ship log to Log Server
IF NOT EXIST "\\%$LOG_SERVER%\%$LOG_SERVER_SHARE%" mkdir "\\%$LOG_SERVER%\%$LOG_SERVER_SHARE%" 2>nul
REM Getting skipped even though server log exists
:: IF NOT EXIST "\\%$LOG_SERVER%\%$LOG_SERVER_SHARE%" GOTO skipLS
copy /Y "%$LogPath%\%$Log%" "\\%$LOG_SERVER%\%$LOG_SERVER_SHARE%"
:skipLS
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:End
EXIT /B