icacls C:\srv\ts-guard.ps1 /inheritance:r /grant "SYSTEM:(F)" /grant "Администраторы:(F)"
schtasks /Create /TN "TsGuard" `
/TR "powershell.exe -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File C:\srv\ts-guard.ps1" `
/SC ONSTART /RU SYSTEM /RL HIGHEST /F
$t = Get-ScheduledTask -TaskName "TsGuard"
$t.Settings.RestartCount = 999
$t.Settings.RestartInterval = "PT1M"
$t.Settings.ExecutionTimeLimit = "PT0S"
Set-ScheduledTask -InputObject $t
schtasks /Run /TN "TsGuard"