-
Notifications
You must be signed in to change notification settings - Fork 0
/
SYS-PURGE.LOGS.ps1
49 lines (49 loc) · 2.54 KB
/
SYS-PURGE.LOGS.ps1
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
#--
#-- ************************************************************************************************************:
#-- ******************************************* PURGE LISTEN ONLY LOG ******************************************:
#-- ************************************************************************************************************:
#-- Author: JBALLARD (JEB) :
#-- Date: 2023.11.10 :
#-- Script: SYS-PURGE.LOGS.ps1 :
#-- Dir: C:\SchneiderElectricData\OASyS\Servers\tools\NetworkListener\ :
#-- Purpose: A PowerShell script that purges the TCP Listen Only Log File. :
#-- Version: 1.0 :
#-- ************************************************************************************************************:
#-- ************************************************************************************************************:
#--
#-- ********************************************************:
#-- RUN POWERSHELL SCRIPT WITH ADMIN PRIVILEGES :
#-- ********************************************************:
if (-Not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
WRITE-HOST "NOTE - REQUIRES ADMIN PRIVILEGES:"
EXIT
}
#--
#-- ********************************************************:
#-- DEFINE PARAMS, CONSTANTS, CONFIG PATHS, IMPORT CLASSES :
#-- ********************************************************:
$PURGEPaths = "C:\SchneiderElectricData\OASyS\Servers\tools\NetworkListener\TcpListener.log"
#--
# DOES LOG FILE EXIST?:
if (TEST-PATH $PURGEPaths)
{
try
{
#-- PURGE LOG FILE:
REMOVE-ITEM -PATH $PURGEPaths -FORCE
WRITE-HOST "THE NETWORK LISTEN ONLY LOG '$PURGEPaths' HAS BEEN PURGED:"
}
catch
{
WRITE-HOST "ERROR: FAILED TO PURGE LOG FILE: $($error[0].Exception.Message)"
}
}
else
{
WRITE-HOST "THE LOG FILE '$PURGEPaths' WAS NOT FOUND:"
}
#--
#-- ********************************************************:
#-- END OF SCRIPT :
#-- ********************************************************: