Added creating INI-file.
This commit is contained in:
@@ -25,6 +25,7 @@ if "%1" equ "-U" set update=1
|
|||||||
if "%1" equ "-u" set update=1
|
if "%1" equ "-u" set update=1
|
||||||
if "%1" equ "--update" set update=1
|
if "%1" equ "--update" set update=1
|
||||||
|
|
||||||
powershell -ExecutionPolicy RemoteSigned -File wDayzManager.ps1 %update% > %filename%
|
powershell -ExecutionPolicy RemoteSigned -File wDayzManager.ps1 %update%
|
||||||
|
@REM powershell -ExecutionPolicy RemoteSigned -File wDayzManager.ps1 %update% > %filename%
|
||||||
|
|
||||||
popd
|
popd
|
||||||
|
|||||||
126
wDayzManager.ini
126
wDayzManager.ini
@@ -1,19 +1,22 @@
|
|||||||
; wDayzManager.ini
|
; wDayzManager.ini
|
||||||
[Config]
|
[Config]
|
||||||
serverLocation=Z:\Servers\dayzserver
|
;serverLocation=Z:\Servers\dayzserver
|
||||||
steamCMD=Z:\SteamCMD
|
serverLocation=D:\dayz\server
|
||||||
|
profilesLocation=profiles
|
||||||
|
; steamCMD=Z:\SteamCMD
|
||||||
|
steamCMD=V:\SteamCMD
|
||||||
steamUser=w0lf_2k
|
steamUser=w0lf_2k
|
||||||
appidGame=221100
|
appidGame=221100
|
||||||
appidServer=223350
|
appidServer=223350
|
||||||
|
rotateLogs=0
|
||||||
rotateLogs=1
|
|
||||||
daysAmount=7
|
daysAmount=7
|
||||||
rotatedLogsFolderName=RotatedLogs
|
; rotatedLogsFolderName=RotatedLogs
|
||||||
; rotatedLogsFolderName=
|
rotatedLogsFolderName=
|
||||||
becFolderName=BEC
|
; becFolderName=BEC
|
||||||
; becFolderName=
|
becFolderName=
|
||||||
atFolderName=VPPAdminTools
|
; atFolderName=VPPAdminTools
|
||||||
; atFolderName=CommunityOnlineTools
|
; atFolderName=CommunityOnlineTools
|
||||||
|
atFolderName=
|
||||||
|
|
||||||
; Server updating settings:
|
; Server updating settings:
|
||||||
; D = Daily - Updates are checked daily at the hours specified in parameter 'updateHour' (0 - 23). In this case, parameter 'updateDay' is ignored.
|
; D = Daily - Updates are checked daily at the hours specified in parameter 'updateHour' (0 - 23). In this case, parameter 'updateDay' is ignored.
|
||||||
@@ -25,68 +28,75 @@ updateDay=1
|
|||||||
updateHour=4
|
updateHour=4
|
||||||
|
|
||||||
[ClientMods]
|
[ClientMods]
|
||||||
@GAZ_TIGR=2731398623
|
|
||||||
@CF=1559212036
|
@CF=1559212036
|
||||||
@COT=1564026768
|
@COT=1564026768
|
||||||
@VPPAdminTools=1828439124
|
@VPPAdminTools=1828439124
|
||||||
@VanillaPlusPlusMap=1623711988
|
@VanillaPlusPlusMap=1623711988
|
||||||
@Namalsk_Island=2288339650
|
@Namalsk_Island=2288339650
|
||||||
@Namalsk_Survival=2288336145
|
@Namalsk_Survival=2288336145
|
||||||
@KAMAZ=2561482171
|
@CodeLock=1646187754
|
||||||
|
@KAMAZ_NeonMurder=2561482171
|
||||||
|
@Kamaz_Truck_LaGTeK=1895398348
|
||||||
|
@UralRust=3101355011
|
||||||
|
@VPK3927Volk=3354895140
|
||||||
|
@GAZ_TIGR_by_Savage=2731398623
|
||||||
|
@GAZ_TIGR_by_Fenyx=3323914085
|
||||||
|
@TF_UAZ3151=2618764716
|
||||||
|
@CnG_UAZ_31514=3160244059
|
||||||
|
|
||||||
[ServerMods]
|
[ServerMods]
|
||||||
@SurvivorMissions=1988925918
|
@SurvivorMissions=1988925918
|
||||||
|
|
||||||
[Server-1]
|
; [Server-1]
|
||||||
serverPort=35100
|
; serverPort=35100
|
||||||
serverConfig=serverDZ.cfg
|
|
||||||
serverExeName=DayZServer_x64.exe
|
|
||||||
serverCPU=2
|
|
||||||
startupClientMods=@CF;@VPPadminTools
|
|
||||||
startupServerMods=
|
|
||||||
additionalParams= -name=Server -adminLog
|
|
||||||
namalskMission=
|
|
||||||
|
|
||||||
[Server-2]
|
|
||||||
serverPort=35200
|
|
||||||
serverConfig=serverDZ.cfg
|
|
||||||
serverExeName=DayZServer_x64.exe
|
|
||||||
serverCPU=2
|
|
||||||
startupClientMods=@CF;@VPPadminTools
|
|
||||||
startupServerMods=
|
|
||||||
additionalParams= -name=Server -adminLog
|
|
||||||
namalskMission=
|
|
||||||
|
|
||||||
[Server-3]
|
|
||||||
serverPort=35300
|
|
||||||
serverConfig=serverDZ.cfg
|
|
||||||
serverExeName=DayZServer_x64.exe
|
|
||||||
serverCPU=2
|
|
||||||
startupClientMods=@CF;@VPPadminTools;@Namalsk_Island;@Namalsk_Survival
|
|
||||||
startupServerMods=
|
|
||||||
additionalParams= -name=Server -adminLog
|
|
||||||
namalskMission=Regular
|
|
||||||
|
|
||||||
[Server-4]
|
|
||||||
serverPort=35400
|
|
||||||
serverConfig=serverDZ.cfg
|
|
||||||
serverExeName=DayZServer_x64.exe
|
|
||||||
serverCPU=2
|
|
||||||
startupClientMods=@CF;@VPPadminTools
|
|
||||||
startupServerMods=
|
|
||||||
additionalParams= -name=Server -adminLog
|
|
||||||
namalskMission=
|
|
||||||
|
|
||||||
; [Server-5]
|
|
||||||
; serverPort=35500
|
|
||||||
; serverConfig=serverDZ.cfg
|
; serverConfig=serverDZ.cfg
|
||||||
; serverExeName=DayZServer_x64.exe
|
; serverExeName=DayZServer_x64.exe
|
||||||
; serverCPU=4
|
; serverCPU=2
|
||||||
; ; startupClientMods=@CF;@COT
|
; startupClientMods=@CF;@VPPadminTools
|
||||||
; startupClientMods=@CF;@VPPAdminTools;@Namalsk_Island;@Namalsk_Survival
|
|
||||||
; startupServerMods=
|
; startupServerMods=
|
||||||
; additionalParams= -name=Server -filePatching
|
; additionalParams= -name=Server -adminLog
|
||||||
; namalskMission=Hardcore
|
; namalskMission=
|
||||||
|
|
||||||
|
; [Server-2]
|
||||||
|
; serverPort=35200
|
||||||
|
; serverConfig=serverDZ.cfg
|
||||||
|
; serverExeName=DayZServer_x64.exe
|
||||||
|
; serverCPU=2
|
||||||
|
; startupClientMods=@CF;@VPPadminTools
|
||||||
|
; startupServerMods=
|
||||||
|
; additionalParams= -name=Server -adminLog
|
||||||
|
; namalskMission=
|
||||||
|
|
||||||
|
; [Server-3]
|
||||||
|
; serverPort=35300
|
||||||
|
; serverConfig=serverDZ.cfg
|
||||||
|
; serverExeName=DayZServer_x64.exe
|
||||||
|
; serverCPU=2
|
||||||
|
; startupClientMods=@CF;@VPPadminTools;@Namalsk_Island;@Namalsk_Survival
|
||||||
|
; startupServerMods=
|
||||||
|
; additionalParams= -name=Server -adminLog
|
||||||
|
; namalskMission=Regular
|
||||||
|
|
||||||
|
; [Server-4]
|
||||||
|
; serverPort=35400
|
||||||
|
; serverConfig=serverDZ.cfg
|
||||||
|
; serverExeName=DayZServer_x64.exe
|
||||||
|
; serverCPU=2
|
||||||
|
; startupClientMods=@CF;@VPPadminTools
|
||||||
|
; startupServerMods=
|
||||||
|
; additionalParams= -name=Server -adminLog
|
||||||
|
; namalskMission=
|
||||||
|
|
||||||
|
[Server-5]
|
||||||
|
serverPort=35500
|
||||||
|
serverConfig=serverDZ.cfg
|
||||||
|
serverExeName=DayZServer_x64.exe
|
||||||
|
serverCPU=2
|
||||||
|
startupClientMods=
|
||||||
|
; startupClientMods=@CF;@VPPAdminTools;@Namalsk_Island;@Namalsk_Survival
|
||||||
|
startupServerMods=
|
||||||
|
additionalParams= -name=Server
|
||||||
|
namalskMission=Hardcore
|
||||||
|
|
||||||
; [Server-6]
|
; [Server-6]
|
||||||
; serverPort=35600
|
; serverPort=35600
|
||||||
|
|||||||
180
wDayzManager.ps1
180
wDayzManager.ps1
@@ -7,16 +7,79 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
param (
|
param (
|
||||||
[Parameter()]
|
[Parameter()]
|
||||||
[int]
|
[int]$param = 0
|
||||||
$param = 0
|
|
||||||
)
|
)
|
||||||
[bool]$update = $param
|
[bool]$update = $param
|
||||||
|
|
||||||
[bool]$noDelete = $false # For tests - don't delete logs
|
[bool]$noDelete = $false # For tests - don't delete logs
|
||||||
[string]$logFile = ".\wDayzManager.log"
|
|
||||||
[string]$steamScript = "wDayzManager.txt"
|
###############################################################################################################################################################
|
||||||
[string]$iniFile = ".\wDayzManager.ini"
|
[string]$myName = "wDayzManager"
|
||||||
if (-not (Test-Path $iniFile)) {
|
[string]$steamScript = $myName + ".txt"
|
||||||
Write-Error "Can't find file '$iniFile'"
|
[string]$iniFile = $myName + ".ini"
|
||||||
|
if (-not (Test-Path -Path $iniFile)) {
|
||||||
|
Write-Warning "Can't find file '$iniFile', creating new..."
|
||||||
|
New-Item -ItemType File -Path $iniFile -Value "; $($iniFile)" | Out-Null
|
||||||
|
$content = "
|
||||||
|
[Config]
|
||||||
|
serverLocation=Z:\Servers\DayzServer
|
||||||
|
profilesLocation=profiles
|
||||||
|
steamCMD=Z:\SteamCMD
|
||||||
|
steamUser=SupaMegaGamer
|
||||||
|
appidGame=221100
|
||||||
|
appidServer=223350
|
||||||
|
rotateLogs=1
|
||||||
|
daysAmount=7
|
||||||
|
rotatedLogsFolderName=RotatedLogs
|
||||||
|
becFolderName=BEC
|
||||||
|
atFolderName=VPPAdminTools
|
||||||
|
|
||||||
|
; Server updating settings:
|
||||||
|
; D = Daily - Updates are checked daily at the hours specified in parameter 'updateHour' (0 - 23). In this case, parameter 'updateDay' is ignored.
|
||||||
|
; W = Weekly - Updates are checked weekly at the hours specified in parameter 'updateHour' (0 - 23). Parameter 'updateDay' specifies the day of the week (0 - 6, 0 = Sunday).
|
||||||
|
; M = Monthly - Updates are checked monthly at the hours specified in parameter 'updateHour' (0 - 23). Parameter 'updateDay' specifies the day of the month (1 - 31. Be careful with February!).
|
||||||
|
; Any other value disables the updates.
|
||||||
|
updatePeriod=W
|
||||||
|
updateDay=1
|
||||||
|
updateHour=4
|
||||||
|
|
||||||
|
[ClientMods]
|
||||||
|
@CF=1559212036
|
||||||
|
@Namalsk_Island=2288339650
|
||||||
|
@Namalsk_Survival=2288336145
|
||||||
|
|
||||||
|
[ServerMods]
|
||||||
|
|
||||||
|
[Server-1]
|
||||||
|
serverPort=2302
|
||||||
|
serverConfig=serverDZ.cfg
|
||||||
|
serverExeName=DayZServer_x64.exe
|
||||||
|
serverCPU=2
|
||||||
|
startupClientMods=@CF
|
||||||
|
startupServerMods=
|
||||||
|
additionalParams= -name=Server
|
||||||
|
|
||||||
|
; Mission name for Namalsk Mod
|
||||||
|
; This is the name of the Namalsk mod mission. It can be 'Hardcore' or 'Regular', i.e. the names of folders in the '@Namalsk_Survival\Extras\' directory.
|
||||||
|
; If you are not using Namalsk mod, this parameter is ignored.
|
||||||
|
namalskMission=
|
||||||
|
|
||||||
|
[Server-2]
|
||||||
|
serverPort=2402
|
||||||
|
serverConfig=serverDZ.cfg
|
||||||
|
serverExeName=DayZServer_x64.exe
|
||||||
|
serverCPU=2
|
||||||
|
startupClientMods=@CF;@Namalsk_Island;@Namalsk_Survival
|
||||||
|
startupServerMods=
|
||||||
|
additionalParams= -name=Server -AdminLog -FilePatching
|
||||||
|
|
||||||
|
; Mission name for Namalsk Mod
|
||||||
|
; This is the name of the Namalsk mod mission. It can be 'Hardcore' or 'Regular', i.e. the names of folders in the '@Namalsk_Survival\Extras\' directory.
|
||||||
|
; If you are not using Namalsk mod, this parameter is ignored.
|
||||||
|
namalskMission=Hardcore
|
||||||
|
"
|
||||||
|
Add-Content -Path $iniFile -Value $content -Encoding UTF8
|
||||||
|
$content = $null
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,17 +94,19 @@ Write-Host "update = $($update), noDelete = $($noDelete)"
|
|||||||
|
|
||||||
$ini = $config = $servers = $clientMods = $serverMods = $steamProcess = $null
|
$ini = $config = $servers = $clientMods = $serverMods = $steamProcess = $null
|
||||||
$modNI = $modNS = $namalskMission = $pathNamalskMission = $null
|
$modNI = $modNS = $namalskMission = $pathNamalskMission = $null
|
||||||
$dayzProcess = $becProcess = $instance = $null
|
$dayzProcess = $becProcess = $instance = $profilesLocation = $null
|
||||||
$becLocation = $rotatedLogsFolderName = $atFolderName = $serverLocation = $null
|
$becLocation = $rotatedLogsFolderName = $atFolderName = $serverLocation = $null
|
||||||
$steamCMD = $steamUser = $appidServer = $appidGame = $rotateLogs = $daysAmount = $null
|
$steamCMD = $steamUser = $appidServer = $appidGame = $rotateLogs = $daysAmount = $null
|
||||||
$serverPort = $serverConfig = $serverExeName = $serverCPU = $null
|
$serverPort = $serverConfig = $serverExeName = $serverCPU = $null
|
||||||
$startupClientMods = $startupServerMods = $startupMods = $startupParams = $null
|
$startupClientMods = $startupServerMods = $startupMods = $startupParams = $null
|
||||||
$serverProfile = $additionalParams = $dayzArguments = $dayz = $bec = $becArguments = $null
|
$serverProfile = $additionalParams = $dayzArguments = $dayz = $bec = $becArguments = $null
|
||||||
$logsName = $atLogsLocation = $becLogsLocation = $rotatedLogsLocation = $null
|
$logsName = $atLogsLocation = $becLogsLocation = $rotatedLogsLocation = $null
|
||||||
|
$currentPath = Get-Location
|
||||||
|
|
||||||
$ini = (Get-IniContent -FilePath $iniFile)
|
$ini = (Get-IniContent -FilePath $iniFile)
|
||||||
$config = $ini.Config
|
$config = $ini.Config
|
||||||
[string]$serverLocation = $config.serverLocation
|
[string]$serverLocation = $config.serverLocation
|
||||||
|
[string]$profilesLocation = $config.profilesLocation
|
||||||
[string]$steamCMD = $config.steamCMD
|
[string]$steamCMD = $config.steamCMD
|
||||||
[string]$steamUser = $config.steamUser
|
[string]$steamUser = $config.steamUser
|
||||||
[int]$appidGame = $config.appidGame
|
[int]$appidGame = $config.appidGame
|
||||||
@@ -81,12 +146,10 @@ if ($update) {
|
|||||||
Write-Host "Start updating server..."
|
Write-Host "Start updating server..."
|
||||||
|
|
||||||
if (-not (Test-Path $steamCMD)) {
|
if (-not (Test-Path $steamCMD)) {
|
||||||
Write-Error "Can't find folder '$steamCMD'"
|
Write-Error "Can't find folder '$steamCMD'!"
|
||||||
Exit
|
Exit
|
||||||
}
|
}
|
||||||
|
|
||||||
$currentPath = Get-Location
|
|
||||||
|
|
||||||
# Making Steam script
|
# Making Steam script
|
||||||
$arr = @()
|
$arr = @()
|
||||||
$arr += "@NoPromptForPassword 1"
|
$arr += "@NoPromptForPassword 1"
|
||||||
@@ -99,8 +162,8 @@ if ($update) {
|
|||||||
$arr += "quit"
|
$arr += "quit"
|
||||||
|
|
||||||
# Saving Steam script
|
# Saving Steam script
|
||||||
"// wDayzManager.txt - Steam script" | Out-File -FilePath "$($currentPath)\$($steamScript)" -Encoding ascii
|
"// $($steamScript) - Steam script" | Out-File -FilePath "$($currentPath)\$($steamScript)" -Encoding Ascii
|
||||||
$arr | Out-File -FilePath "$($currentPath)\$($steamScript)" -Encoding ascii -Append
|
$arr | Out-File -FilePath "$($currentPath)\$($steamScript)" -Encoding Ascii -Append
|
||||||
|
|
||||||
# Run Steam script
|
# Run Steam script
|
||||||
Write-Host "Run Steam script from `"$($currentPath)\$($steamScript)`""
|
Write-Host "Run Steam script from `"$($currentPath)\$($steamScript)`""
|
||||||
@@ -167,6 +230,10 @@ if ($rotateLogs) {
|
|||||||
if (-not ([string]::IsNullOrEmpty($config.rotatedLogsFolderName))) {
|
if (-not ([string]::IsNullOrEmpty($config.rotatedLogsFolderName))) {
|
||||||
$rotatedLogsFolderName = $config.rotatedLogsFolderName
|
$rotatedLogsFolderName = $config.rotatedLogsFolderName
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Write-Error "The 'rotatedLogsFolderName' parameter not set!"
|
||||||
|
Exit
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-not ([string]::IsNullOrEmpty($config.becFolderName))) {
|
if (-not ([string]::IsNullOrEmpty($config.becFolderName))) {
|
||||||
@@ -181,8 +248,12 @@ $servers += $ini.Keys.Where({ $_ -Match "^[Ss]erver[\s_-]?[0-9]+$" })
|
|||||||
|
|
||||||
$processID = 0
|
$processID = 0
|
||||||
$dayzProcess = [Object[]]::new($servers.Count)
|
$dayzProcess = [Object[]]::new($servers.Count)
|
||||||
$becProcess = [Object[]]::new($servers.Count)
|
|
||||||
$dayzArguments = @()
|
$dayzArguments = @()
|
||||||
|
if ($becLocation) {
|
||||||
|
$becProcess = [Object[]]::new($servers.Count)
|
||||||
|
}
|
||||||
|
|
||||||
|
EXIT
|
||||||
|
|
||||||
foreach ($srv in $servers) {
|
foreach ($srv in $servers) {
|
||||||
$instance = ${srv}
|
$instance = ${srv}
|
||||||
@@ -222,19 +293,18 @@ foreach ($srv in $servers) {
|
|||||||
|
|
||||||
# Rotate logs
|
# Rotate logs
|
||||||
if ($rotateLogs) {
|
if ($rotateLogs) {
|
||||||
if ($atFolderName) {
|
if ($rotatedLogsFolderName) {
|
||||||
$atLogsLocation = "$($serverProfile)\$($atFolderName)"
|
$rotatedLogsLocation = "$($serverProfile)\$($rotatedLogsFolderName)"
|
||||||
|
|
||||||
$logsName = Get-ChildItem -Path $atLogsLocation -Directory -Filter "Log*"
|
|
||||||
$atLogsLocation += '\' + $logsName
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($becLocation) {
|
if ($becLocation) {
|
||||||
$becLogsLocation = "$($becLocation)\Log\$($instance)"
|
$becLogsLocation = "$($becLocation)\Log\$($instance)"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($rotatedLogsFolderName) {
|
if ($atFolderName) {
|
||||||
$rotatedLogsLocation = "$($serverProfile)\$($rotatedLogsFolderName)"
|
$atLogsLocation = "$($serverProfile)\$($atFolderName)"
|
||||||
|
$logsName = Get-ChildItem -Path $atLogsLocation -Directory -Filter "Log*"
|
||||||
|
$atLogsLocation += '\' + $logsName
|
||||||
}
|
}
|
||||||
|
|
||||||
If (!(Test-Path -PathType Container $rotatedLogsLocation)) {
|
If (!(Test-Path -PathType Container $rotatedLogsLocation)) {
|
||||||
@@ -242,13 +312,17 @@ foreach ($srv in $servers) {
|
|||||||
Write-Host "Created new folder: $($rotatedLogsLocation)"
|
Write-Host "Created new folder: $($rotatedLogsLocation)"
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileList = $null
|
if ($noDelete) {
|
||||||
$destDelDir = "$($rotatedLogsLocation)\DeletedLogs"
|
$destDelDir = "$($rotatedLogsLocation)\DeletedLogs"
|
||||||
$becDestDir = "$($rotatedLogsLocation)\BEC"
|
If (!(Test-Path -PathType Container $destDelDir)) {
|
||||||
$atDestDir = "$($rotatedLogsLocation)\$($atFolderName)"
|
New-Item -ItemType Directory -Path $destDelDir | Out-Null
|
||||||
|
Write-Host "Created new folder: $($destDelDir)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region ### DayZ Game ###
|
#region ### DayZ Game ###
|
||||||
Write-Host "Rotating DAYZ logs..."
|
Write-Host "Rotating DAYZ logs..."
|
||||||
|
$fileList = $null
|
||||||
$fileList = Get-Item -Path $serverProfile\*.rpt, $serverProfile\*.log, $serverProfile\*.adm, $serverProfile\*.mdmp | Where-Object { $_.LastWriteTime.Date -lt $date.Date }
|
$fileList = Get-Item -Path $serverProfile\*.rpt, $serverProfile\*.log, $serverProfile\*.adm, $serverProfile\*.mdmp | Where-Object { $_.LastWriteTime.Date -lt $date.Date }
|
||||||
# Write-Host $fileList -Separator "`n"
|
# Write-Host $fileList -Separator "`n"
|
||||||
|
|
||||||
@@ -262,42 +336,36 @@ foreach ($srv in $servers) {
|
|||||||
$fileList = Get-Item -Path $rotatedLogsLocation\*.rpt, $rotatedLogsLocation\*.log, $rotatedLogsLocation\*.adm, $rotatedLogsLocation\*.mdmp | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
|
$fileList = Get-Item -Path $rotatedLogsLocation\*.rpt, $rotatedLogsLocation\*.log, $rotatedLogsLocation\*.adm, $rotatedLogsLocation\*.mdmp | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
|
||||||
# Write-Host $fileList -Separator "`n"
|
# Write-Host $fileList -Separator "`n"
|
||||||
|
|
||||||
Write-Host "Removing logs:"
|
Write-Host "Removing DayZ logs:"
|
||||||
if ($noDelete) {
|
|
||||||
If (!(Test-Path -PathType Container $destDelDir)) {
|
|
||||||
New-Item -ItemType Directory -Path $destDelDir | Out-Null
|
|
||||||
Write-Host "Created new folder: $($destDelDir)"
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($file in $fileList) {
|
foreach ($file in $fileList) {
|
||||||
|
if ($noDelete) {
|
||||||
Move-Item -Path $file -Destination $destDelDir -Force
|
Move-Item -Path $file -Destination $destDelDir -Force
|
||||||
Write-Host "Moved $($file) to $($destDelDir)"
|
Write-Host "Moved $($file) to $($destDelDir)"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
foreach ($file in $fileList) {
|
|
||||||
Remove-Item -Path $file
|
Remove-Item -Path $file
|
||||||
Write-Host "Removed $($file)!"
|
Write-Host "Removed $($file)!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Host "Total: $($fileList.Count)"
|
Write-Host "Total: $($fileList.Count)"
|
||||||
Write-Host ""
|
Write-Host
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ### BEC ###
|
#region ### BEC ###
|
||||||
if ($becDestDir) {
|
if ($becLocation) {
|
||||||
Write-Host "Rotating BEC logs..."
|
$becDestDir = "$($rotatedLogsLocation)\$($becFolderName)"
|
||||||
$fileList = $null
|
|
||||||
|
|
||||||
If (!(Test-Path -PathType Container $becDestDir)) {
|
If (!(Test-Path -PathType Container $becDestDir)) {
|
||||||
New-Item -ItemType Directory -Path $becDestDir | Out-Null
|
New-Item -ItemType Directory -Path $becDestDir | Out-Null
|
||||||
Write-Host "Created new folder: $($becDestDir)"
|
Write-Host "Created new folder: $($becDestDir)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Host "Rotating BEC logs..."
|
||||||
|
$fileList = $null
|
||||||
$fileList = Get-ChildItem -Path $becLogsLocation\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.Date }
|
$fileList = Get-ChildItem -Path $becLogsLocation\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.Date }
|
||||||
# Write-Host $fileList -Separator "`n"
|
# Write-Host $fileList -Separator "`n"
|
||||||
|
|
||||||
Write-Host "Moving BEC's LOGs to $($becDestDir):"
|
Write-Host "Moving BEC logs to $($becDestDir):"
|
||||||
foreach ($file in $fileList) {
|
foreach ($file in $fileList) {
|
||||||
Move-Item -Path $file -Destination $becDestDir -Force
|
Move-Item -Path $file -Destination $becDestDir -Force
|
||||||
Write-Host "Moved $($file) to $($becDestDir)"
|
Write-Host "Moved $($file) to $($becDestDir)"
|
||||||
@@ -307,43 +375,37 @@ foreach ($srv in $servers) {
|
|||||||
$fileList = Get-Item -Path $becDestDir\*.log | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
|
$fileList = Get-Item -Path $becDestDir\*.log | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
|
||||||
# Write-Host $fileList -Separator "`n"
|
# Write-Host $fileList -Separator "`n"
|
||||||
|
|
||||||
Write-Host "Removing BEC's LOGs:"
|
Write-Host "Removing BEC logs:"
|
||||||
if ($noDelete) {
|
|
||||||
If (!(Test-Path -PathType Container $destDelDir)) {
|
|
||||||
New-Item -ItemType Directory -Path $destDelDir | Out-Null
|
|
||||||
Write-Host "Created new folder: $($destDelDir)"
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($file in $fileList) {
|
foreach ($file in $fileList) {
|
||||||
Move-Item -Path $file -Destination $destDelDir
|
if ($noDelete) {
|
||||||
|
Move-Item -Path $file -Destination $destDelDir -Force
|
||||||
Write-Host "Moved $($file) to $($destDelDir)"
|
Write-Host "Moved $($file) to $($destDelDir)"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
foreach ($file in $fileList) {
|
|
||||||
Remove-Item -Path $file
|
Remove-Item -Path $file
|
||||||
Write-Host "Removed $($file)!"
|
Write-Host "Removed $($file)!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Host "Total: $($fileList.Count)"
|
Write-Host "Total: $($fileList.Count)"
|
||||||
Write-Host ""
|
Write-Host
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ### Admin Tool ###
|
#region ### Admin Tool ###
|
||||||
if ($atDestDir) {
|
if ($atLogsLocation) {
|
||||||
Write-Host "Rotating AdminTool logs..."
|
$atDestDir = "$($rotatedLogsLocation)\$($atFolderName)"
|
||||||
$fileList = $null
|
|
||||||
|
|
||||||
If (!(Test-Path -PathType Container $atDestDir)) {
|
If (!(Test-Path -PathType Container $atDestDir)) {
|
||||||
New-Item -ItemType Directory -Path $atDestDir | Out-Null
|
New-Item -ItemType Directory -Path $atDestDir | Out-Null
|
||||||
Write-Host "Created new folder: $($atDestDir)"
|
Write-Host "Created new folder: $($atDestDir)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Write-Host "Rotating AdminTool logs..."
|
||||||
|
$fileList = $null
|
||||||
$fileList = Get-ChildItem -Path $atLogsLocation\*.txt, $atLogsLocation\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.Date }
|
$fileList = Get-ChildItem -Path $atLogsLocation\*.txt, $atLogsLocation\*.log -Recurse | Where-Object { $_.LastWriteTime.Date -lt $date.Date }
|
||||||
# Write-Host $fileList -Separator "`n"
|
# Write-Host $fileList -Separator "`n"
|
||||||
|
|
||||||
Write-Host "Moving AdminTool's LOGs to $($atDestDir):"
|
Write-Host "Moving AdminTool logs to $($atDestDir):"
|
||||||
foreach ($file in $fileList) {
|
foreach ($file in $fileList) {
|
||||||
Move-Item -Path $file -Destination $atDestDir -Force
|
Move-Item -Path $file -Destination $atDestDir -Force
|
||||||
Write-Host "Moved $($file) to $($atDestDir)"
|
Write-Host "Moved $($file) to $($atDestDir)"
|
||||||
@@ -353,26 +415,20 @@ foreach ($srv in $servers) {
|
|||||||
$fileList = Get-Item -Path $atDestDir\*.txt, $atDestDir\*.log | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
|
$fileList = Get-Item -Path $atDestDir\*.txt, $atDestDir\*.log | Where-Object { $_.LastWriteTime -lt $date.AddDays( - ($daysAmount)) }
|
||||||
# Write-Host $fileList -Separator "`n"
|
# Write-Host $fileList -Separator "`n"
|
||||||
|
|
||||||
Write-Host "Removing AdminTool's LOGs:"
|
Write-Host "Removing AdminTool logs:"
|
||||||
if ($noDelete) {
|
|
||||||
If (!(Test-Path -PathType Container $destDelDir)) {
|
|
||||||
New-Item -ItemType Directory -Path $destDelDir | Out-Null
|
|
||||||
Write-Host "Created new folder: $($destDelDir)"
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($file in $fileList) {
|
foreach ($file in $fileList) {
|
||||||
|
if ($noDelete) {
|
||||||
Move-Item -Path $file -Destination $destDelDir -Force
|
Move-Item -Path $file -Destination $destDelDir -Force
|
||||||
Write-Host "Moved $($file) to $($destDelDir)"
|
Write-Host "Moved $($file) to $($destDelDir)"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
foreach ($file in $fileList) {
|
|
||||||
Remove-Item -Path $file
|
Remove-Item -Path $file
|
||||||
Write-Host "Removed $($file)!"
|
Write-Host "Removed $($file)!"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Write-Host "Total: $($fileList.Count)"
|
Write-Host "Total: $($fileList.Count)"
|
||||||
Write-Host ""
|
Write-Host
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user