Version 1.2.1.0 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot.
Przykład zaplanowanego zadania
Ten przykład pokazuje, jak utworzyć zaplanowane zadanie Windows, które codziennie uruchamia skrypt PowerShell do przetwarzania dzienników debugowania DNS.
For AI agents: a documentation index is available at /llms.txt; a markdown version of this page is available at /v1.2.1.0/pl/docs/examples/scheduletask/index.md.
Ten skrypt tworzy zaplanowane zadanie Windows, które uruchamia się codziennie o 2:00 rano. Importuje moduł i przetwarza wszystkie pliki dziennika w folderze, w którym jest wykonywany skrypt (w tym przykładzie “C:\Administration\Logs\DNS”). Proces kompresuje wynik do plików ZIP i usuwa oryginały, aby zachować porządek.
$actionParams = @{
Execute = "powershell.exe"
Argument = '-ExecutionPolicy RemoteSigned -Command "Import-Module DNSServer.DebugLogParser; Get-ChildItem .\*.log | Sort-Object lastwritetime, Name -Descending | Convert-DNSDebugLogFile -ComputerName $env:COMPUTERNAME -Delimiter \";\" -OutputType Both -ContextFilter Packet -OutputCulture sv-SE -CompressOutput"'
WorkingDirectory = "C:\Administration\Logs\DNS"
}
$Action = New-ScheduledTaskAction @actionParams
$Trigger = New-ScheduledTaskTrigger -Daily -At "2:00AM"
Register-ScheduledTask -TaskName "Process DNS Logs" -Action $Action -Trigger $Trigger -Description "Convert DNS debug logs to CSV daily"