fix: deploy TaskQuery init must load Resolved helper (2.0.30-SAC)
Verify TaskQuery module by Get-RdpMonitorScheduledTaskExecutionTimeLimitResolved, prefer share path over stale InstallRoot, and guard verification when init fails.
This commit is contained in:
+33
-16
@@ -973,11 +973,14 @@ function Stop-RdpLoginMonitorMainProcesses {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Test-RdpMonitorDeployTaskQueryReady {
|
||||||
|
return [bool](Get-Command Get-RdpMonitorScheduledTaskExecutionTimeLimitResolved -ErrorAction SilentlyContinue)
|
||||||
|
}
|
||||||
|
|
||||||
function Import-RdpMonitorDeployTaskQueryModule {
|
function Import-RdpMonitorDeployTaskQueryModule {
|
||||||
param([string]$ShareRoot = '')
|
param([string]$ShareRoot = '')
|
||||||
|
|
||||||
$candidates = [System.Collections.Generic.List[string]]::new()
|
$candidates = [System.Collections.Generic.List[string]]::new()
|
||||||
$candidates.Add((Join-Path $InstallRoot 'RdpMonitor-TaskQuery.ps1')) | Out-Null
|
|
||||||
if (-not [string]::IsNullOrWhiteSpace($ShareRoot)) {
|
if (-not [string]::IsNullOrWhiteSpace($ShareRoot)) {
|
||||||
$candidates.Add((Join-Path $ShareRoot 'RdpMonitor-TaskQuery.ps1')) | Out-Null
|
$candidates.Add((Join-Path $ShareRoot 'RdpMonitor-TaskQuery.ps1')) | Out-Null
|
||||||
}
|
}
|
||||||
@@ -985,17 +988,21 @@ function Import-RdpMonitorDeployTaskQueryModule {
|
|||||||
if ([string]::IsNullOrWhiteSpace($deployScriptPath)) { $deployScriptPath = $MyInvocation.MyCommand.Path }
|
if ([string]::IsNullOrWhiteSpace($deployScriptPath)) { $deployScriptPath = $MyInvocation.MyCommand.Path }
|
||||||
if (-not [string]::IsNullOrWhiteSpace($deployScriptPath)) {
|
if (-not [string]::IsNullOrWhiteSpace($deployScriptPath)) {
|
||||||
$candidates.Add((Join-Path (Split-Path -Parent $deployScriptPath) 'RdpMonitor-TaskQuery.ps1')) | Out-Null
|
$candidates.Add((Join-Path (Split-Path -Parent $deployScriptPath) 'RdpMonitor-TaskQuery.ps1')) | Out-Null
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$candidates.Add((Join-Path (Resolve-SourceShareRoot) 'RdpMonitor-TaskQuery.ps1')) | Out-Null
|
|
||||||
} catch { }
|
|
||||||
}
|
}
|
||||||
|
$candidates.Add((Join-Path $InstallRoot 'RdpMonitor-TaskQuery.ps1')) | Out-Null
|
||||||
|
|
||||||
foreach ($candidate in @($candidates)) {
|
foreach ($candidate in @($candidates)) {
|
||||||
if (Test-Path -LiteralPath $candidate) {
|
if (-not (Test-Path -LiteralPath $candidate)) { continue }
|
||||||
|
try {
|
||||||
. $candidate
|
. $candidate
|
||||||
|
} catch {
|
||||||
|
Write-DeployLog "Предупреждение: не удалось загрузить $candidate — $($_.Exception.Message)"
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (Test-RdpMonitorDeployTaskQueryReady) {
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
Write-DeployLog "Предупреждение: $candidate загружен, но функции TaskQuery недоступны — пробуем следующий источник."
|
||||||
}
|
}
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
@@ -1003,16 +1010,16 @@ function Import-RdpMonitorDeployTaskQueryModule {
|
|||||||
function Initialize-RdpMonitorDeployTaskQuery {
|
function Initialize-RdpMonitorDeployTaskQuery {
|
||||||
param([string]$ShareRoot = '')
|
param([string]$ShareRoot = '')
|
||||||
|
|
||||||
if (Get-Command Test-RdpMonitorScheduledTaskNeedsUnlimitedExecutionTimeLimit -ErrorAction SilentlyContinue) {
|
if (Test-RdpMonitorDeployTaskQueryReady) {
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
if (Import-RdpMonitorDeployTaskQueryModule -ShareRoot $ShareRoot) {
|
if (Import-RdpMonitorDeployTaskQueryModule -ShareRoot $ShareRoot) {
|
||||||
return $true
|
return $true
|
||||||
}
|
}
|
||||||
|
|
||||||
Write-DeployLog "RdpMonitor-TaskQuery.ps1 не найден — deploy использует встроенную проверку schtasks /XML."
|
Write-DeployLog "RdpMonitor-TaskQuery.ps1 недоступен — deploy использует встроенную проверку schtasks /XML."
|
||||||
. $script:RdpMonitorDeployTaskQueryInlineScript
|
. $script:RdpMonitorDeployTaskQueryInlineScript
|
||||||
return $true
|
return (Test-RdpMonitorDeployTaskQueryReady)
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:RdpMonitorDeployTaskQueryInlineScript = {
|
$script:RdpMonitorDeployTaskQueryInlineScript = {
|
||||||
@@ -1101,9 +1108,12 @@ $script:RdpMonitorDeployTaskQueryInlineScript = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Test-RdpMonitorDeployMainTaskNeedsUnlimitedExecutionTime {
|
function Test-RdpMonitorDeployMainTaskNeedsUnlimitedExecutionTime {
|
||||||
param([string]$TaskName = 'RDP-Login-Monitor')
|
param(
|
||||||
if (-not (Get-Command Test-RdpMonitorScheduledTaskNeedsUnlimitedExecutionTimeLimit -ErrorAction SilentlyContinue)) {
|
[string]$TaskName = 'RDP-Login-Monitor',
|
||||||
return $true
|
[string]$ShareRoot = ''
|
||||||
|
)
|
||||||
|
if (-not (Test-RdpMonitorDeployTaskQueryReady)) {
|
||||||
|
if (-not (Initialize-RdpMonitorDeployTaskQuery -ShareRoot $ShareRoot)) { return $true }
|
||||||
}
|
}
|
||||||
return (Test-RdpMonitorScheduledTaskNeedsUnlimitedExecutionTimeLimit -TaskName $TaskName)
|
return (Test-RdpMonitorScheduledTaskNeedsUnlimitedExecutionTimeLimit -TaskName $TaskName)
|
||||||
}
|
}
|
||||||
@@ -1117,7 +1127,15 @@ function Get-RdpMonitorDeployMainTaskExecutionTimeLimitLabel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Write-RdpMonitorDeployScheduledTaskVerification {
|
function Write-RdpMonitorDeployScheduledTaskVerification {
|
||||||
param([string]$TaskName = 'RDP-Login-Monitor')
|
param(
|
||||||
|
[string]$TaskName = 'RDP-Login-Monitor',
|
||||||
|
[string]$ShareRoot = ''
|
||||||
|
)
|
||||||
|
|
||||||
|
if (-not (Initialize-RdpMonitorDeployTaskQuery -ShareRoot $ShareRoot)) {
|
||||||
|
Write-DeployLog "ПРЕДУПРЕЖДЕНИЕ: проверка ExecutionTimeLimit недоступна (TaskQuery не инициализирован)."
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
|
||||||
$resolved = Get-RdpMonitorScheduledTaskExecutionTimeLimitResolved -TaskName $TaskName
|
$resolved = Get-RdpMonitorScheduledTaskExecutionTimeLimitResolved -TaskName $TaskName
|
||||||
if ($resolved.Source -eq 'schtasks-xml') {
|
if ($resolved.Source -eq 'schtasks-xml') {
|
||||||
@@ -1211,7 +1229,7 @@ try {
|
|||||||
$needsExchangeNoisePatch = Test-RdpMonitorSettingsNeedsExchangeNoisePatch -SettingsPath $settingsLocal
|
$needsExchangeNoisePatch = Test-RdpMonitorSettingsNeedsExchangeNoisePatch -SettingsPath $settingsLocal
|
||||||
$needsWinRmInboundBlock = Test-RdpMonitorSettingsNeedsWinRmInboundBlock -SettingsPath $settingsLocal
|
$needsWinRmInboundBlock = Test-RdpMonitorSettingsNeedsWinRmInboundBlock -SettingsPath $settingsLocal
|
||||||
$needsBundleSync = Test-RdpMonitorDeployBundleNeedsSync -ShareRoot $shareRoot
|
$needsBundleSync = Test-RdpMonitorDeployBundleNeedsSync -ShareRoot $shareRoot
|
||||||
$needsTaskExecutionLimitFix = Test-RdpMonitorDeployMainTaskNeedsUnlimitedExecutionTime
|
$needsTaskExecutionLimitFix = Test-RdpMonitorDeployMainTaskNeedsUnlimitedExecutionTime -ShareRoot $shareRoot
|
||||||
$needsSacBootstrap = $needsSettingsBootstrap -or $needsBundleSync -or $needsDisplayNameHint -or $needsDailyReportHint -or $needsDailyReportRepair -or $needsExchangeNoisePatch -or $needsWinRmInboundBlock -or $needsTaskExecutionLimitFix
|
$needsSacBootstrap = $needsSettingsBootstrap -or $needsBundleSync -or $needsDisplayNameHint -or $needsDailyReportHint -or $needsDailyReportRepair -or $needsExchangeNoisePatch -or $needsWinRmInboundBlock -or $needsTaskExecutionLimitFix
|
||||||
|
|
||||||
if (Test-RdpMonitorExchangeServerRole) {
|
if (Test-RdpMonitorExchangeServerRole) {
|
||||||
@@ -1321,8 +1339,7 @@ try {
|
|||||||
Write-DeployLog "InstallTasks выполнен (код 0)."
|
Write-DeployLog "InstallTasks выполнен (код 0)."
|
||||||
}
|
}
|
||||||
|
|
||||||
[void](Initialize-RdpMonitorDeployTaskQuery -ShareRoot $shareRoot)
|
[void](Write-RdpMonitorDeployScheduledTaskVerification -ShareRoot $shareRoot)
|
||||||
[void](Write-RdpMonitorDeployScheduledTaskVerification)
|
|
||||||
|
|
||||||
[System.IO.File]::WriteAllText($VersionStampPath, "$shareVerRaw`r`n", $Utf8Bom)
|
[System.IO.File]::WriteAllText($VersionStampPath, "$shareVerRaw`r`n", $Utf8Bom)
|
||||||
Write-DeployLog "Записана метка версии: $VersionStampPath"
|
Write-DeployLog "Записана метка версии: $VersionStampPath"
|
||||||
|
|||||||
+1
-1
@@ -90,7 +90,7 @@ $script:SkipLogDetailLimit = 15
|
|||||||
# строки ниже, если правки «мелкие» и вы не хотите менять отображаемую версию в логах).
|
# строки ниже, если правки «мелкие» и вы не хотите менять отображаемую версию в логах).
|
||||||
# Рекомендация: при значимых релизах меняйте и $ScriptVersion, и version.txt одинаково; при только
|
# Рекомендация: при значимых релизах меняйте и $ScriptVersion, и version.txt одинаково; при только
|
||||||
# исправлениях на шаре — достаточно поднять patch в version.txt (например 1.3.0.1).
|
# исправлениях на шаре — достаточно поднять patch в version.txt (например 1.3.0.1).
|
||||||
$ScriptVersion = "2.0.29-SAC"
|
$ScriptVersion = "2.0.30-SAC"
|
||||||
|
|
||||||
# Логи (все под InstallRoot)
|
# Логи (все под InstallRoot)
|
||||||
$LogFile = Join-Path $script:InstallRoot "Logs\login_monitor.log"
|
$LogFile = Join-Path $script:InstallRoot "Logs\login_monitor.log"
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
2.0.29-SAC
|
2.0.30-SAC
|
||||||
|
|||||||
Reference in New Issue
Block a user