-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-watcher.ps1
More file actions
43 lines (36 loc) · 1.45 KB
/
Copy pathinstall-watcher.ps1
File metadata and controls
43 lines (36 loc) · 1.45 KB
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
# Installiert den KnowledgeWikiWatcher als dauerhaften Task
# Einmalig als Admin ausfuehren: .\install-watcher.ps1
$taskName = "KnowledgeWikiWatcher"
$scriptPath = Join-Path $PSScriptRoot "watch.ps1"
$action = New-ScheduledTaskAction `
-Execute "powershell.exe" `
-Argument "-WindowStyle Hidden -ExecutionPolicy Bypass -File `"$scriptPath`"" `
-WorkingDirectory $PSScriptRoot
$trigger = New-ScheduledTaskTrigger -AtLogOn
$settings = New-ScheduledTaskSettingsSet `
-ExecutionTimeLimit (New-TimeSpan -Hours 0) `
-RestartCount 3 `
-RestartInterval (New-TimeSpan -Minutes 1) `
-MultipleInstances IgnoreNew
$principal = New-ScheduledTaskPrincipal `
-UserId $env:USERNAME `
-LogonType Interactive `
-RunLevel Limited
Register-ScheduledTask `
-TaskName $taskName `
-Action $action `
-Trigger $trigger `
-Settings $settings `
-Principal $principal `
-Force
Write-Host "Task '$taskName' registriert." -ForegroundColor Green
Write-Host "Startet automatisch beim naechsten Login." -ForegroundColor Cyan
Write-Host ""
Write-Host "Jetzt sofort starten:" -ForegroundColor Yellow
Write-Host " Start-ScheduledTask -TaskName '$taskName'"
Write-Host ""
Write-Host "Status pruefen:" -ForegroundColor Yellow
Write-Host " Get-ScheduledTask -TaskName '$taskName' | Select-Object State"
Write-Host ""
Write-Host "Deinstallieren:" -ForegroundColor Yellow
Write-Host " Unregister-ScheduledTask -TaskName '$taskName' -Confirm:`$false"