fix: deploy task limit check without TaskQuery helper deps (2.0.31-SAC)
Deploy uses Get-RdpMonitorScheduledTaskExecutionTimeLimitResolved only; no call to Test-RdpMonitorScheduledTaskNeedsUnlimitedExecutionTimeLimit from external module.
This commit is contained in:
+33
-9
@@ -973,6 +973,26 @@ function Stop-RdpLoginMonitorMainProcesses {
|
||||
}
|
||||
}
|
||||
|
||||
function Test-RdpMonitorDeployTaskExecutionLimitUnlimitedValue {
|
||||
param($Limit)
|
||||
|
||||
if ($null -eq $Limit -or $Limit -isnot [TimeSpan]) { return $false }
|
||||
if ($Limit.Ticks -le 0) { return $true }
|
||||
if ($Limit.TotalDays -ge 999) { return $true }
|
||||
return $false
|
||||
}
|
||||
|
||||
function Get-RdpMonitorDeployTaskExecutionTimeLimitLabelFromResolved {
|
||||
param($Resolved)
|
||||
|
||||
if ($null -eq $Resolved) { return '(null)' }
|
||||
if ($Resolved.Source -eq 'missing') { return '(task missing)' }
|
||||
$limit = $Resolved.Limit
|
||||
if ($null -eq $limit) { return '(null)' }
|
||||
if ($limit -is [TimeSpan] -and $limit.Ticks -le 0) { return 'PT0S' }
|
||||
return $limit.ToString()
|
||||
}
|
||||
|
||||
function Test-RdpMonitorDeployTaskQueryReady {
|
||||
return [bool](Get-Command Get-RdpMonitorScheduledTaskExecutionTimeLimitResolved -ErrorAction SilentlyContinue)
|
||||
}
|
||||
@@ -1112,18 +1132,22 @@ function Test-RdpMonitorDeployMainTaskNeedsUnlimitedExecutionTime {
|
||||
[string]$TaskName = 'RDP-Login-Monitor',
|
||||
[string]$ShareRoot = ''
|
||||
)
|
||||
if (-not (Test-RdpMonitorDeployTaskQueryReady)) {
|
||||
if (-not (Initialize-RdpMonitorDeployTaskQuery -ShareRoot $ShareRoot)) { return $true }
|
||||
}
|
||||
return (Test-RdpMonitorScheduledTaskNeedsUnlimitedExecutionTimeLimit -TaskName $TaskName)
|
||||
$resolved = Get-RdpMonitorScheduledTaskExecutionTimeLimitResolved -TaskName $TaskName
|
||||
if ($resolved.Source -eq 'missing') { return $true }
|
||||
return (-not (Test-RdpMonitorDeployTaskExecutionLimitUnlimitedValue -Limit $resolved.Limit))
|
||||
}
|
||||
|
||||
function Get-RdpMonitorDeployMainTaskExecutionTimeLimitLabel {
|
||||
param([string]$TaskName = 'RDP-Login-Monitor')
|
||||
if (-not (Get-Command Get-RdpMonitorScheduledTaskExecutionTimeLimitLabel -ErrorAction SilentlyContinue)) {
|
||||
param(
|
||||
[string]$TaskName = 'RDP-Login-Monitor',
|
||||
[string]$ShareRoot = ''
|
||||
)
|
||||
if (-not (Initialize-RdpMonitorDeployTaskQuery -ShareRoot $ShareRoot)) {
|
||||
return '(TaskQuery not loaded)'
|
||||
}
|
||||
return (Get-RdpMonitorScheduledTaskExecutionTimeLimitLabel -TaskName $TaskName)
|
||||
$resolved = Get-RdpMonitorScheduledTaskExecutionTimeLimitResolved -TaskName $TaskName
|
||||
return (Get-RdpMonitorDeployTaskExecutionTimeLimitLabelFromResolved -Resolved $resolved)
|
||||
}
|
||||
|
||||
function Write-RdpMonitorDeployScheduledTaskVerification {
|
||||
@@ -1142,8 +1166,8 @@ function Write-RdpMonitorDeployScheduledTaskVerification {
|
||||
Write-DeployLog "Задача ${TaskName}: ExecutionTimeLimit проверен через schtasks /XML (Get-ScheduledTask недоступен)."
|
||||
}
|
||||
|
||||
if (Test-RdpMonitorScheduledTaskNeedsUnlimitedExecutionTimeLimit -TaskName $TaskName) {
|
||||
$label = Get-RdpMonitorScheduledTaskExecutionTimeLimitLabel -TaskName $TaskName
|
||||
if (-not (Test-RdpMonitorDeployTaskExecutionLimitUnlimitedValue -Limit $resolved.Limit)) {
|
||||
$label = Get-RdpMonitorDeployTaskExecutionTimeLimitLabelFromResolved -Resolved $resolved
|
||||
Write-DeployLog "ПРЕДУПРЕЖДЕНИЕ: $TaskName ExecutionTimeLimit=$label — ожидался PT0S (без лимита). Проверьте InstallTasks и права администратора."
|
||||
return $false
|
||||
}
|
||||
@@ -1268,7 +1292,7 @@ try {
|
||||
} elseif ($needsWinRmInboundBlock) {
|
||||
Write-DeployLog "Версия совпадает ($shareVerRaw), но в settings отсутствует обязательный блок WinRM inbound — продолжаем деплой."
|
||||
} elseif ($needsTaskExecutionLimitFix) {
|
||||
$limitLabel = Get-RdpMonitorDeployMainTaskExecutionTimeLimitLabel
|
||||
$limitLabel = Get-RdpMonitorDeployMainTaskExecutionTimeLimitLabel -ShareRoot $shareRoot
|
||||
Write-DeployLog "Версия совпадает ($shareVerRaw), но RDP-Login-Monitor имеет ExecutionTimeLimit=$limitLabel — перерегистрируем задачи (InstallTasks)."
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ $script:SkipLogDetailLimit = 15
|
||||
# строки ниже, если правки «мелкие» и вы не хотите менять отображаемую версию в логах).
|
||||
# Рекомендация: при значимых релизах меняйте и $ScriptVersion, и version.txt одинаково; при только
|
||||
# исправлениях на шаре — достаточно поднять patch в version.txt (например 1.3.0.1).
|
||||
$ScriptVersion = "2.0.30-SAC"
|
||||
$ScriptVersion = "2.0.31-SAC"
|
||||
|
||||
# Логи (все под InstallRoot)
|
||||
$LogFile = Join-Path $script:InstallRoot "Logs\login_monitor.log"
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2.0.30-SAC
|
||||
2.0.31-SAC
|
||||
|
||||
Reference in New Issue
Block a user