{"id":"e5915d9c-e41a-4ebd-a503-38d9c4fc1e38","task":"Write a PowerShell script that schedules itself as a recurring background job using Register-ScheduledJob","domain":"learn.microsoft.com","steps":["Define a trigger: $trigger = New-JobTrigger -Daily -At '06:00AM'","Define the script block or file path: $options = New-ScheduledJobOption -RunElevated","Register the job: Register-ScheduledJob -Name 'DailyReport' -ScriptBlock { Get-EventLog -LogName System -Newest 50 | Export-Csv C:\\Logs\\events.csv } -Trigger $trigger -ScheduledJobOption $options","View registered scheduled jobs: Get-ScheduledJob","Retrieve past results: Get-Job -Name 'DailyReport' | Receive-Job -Keep; unregister when no longer needed: Unregister-ScheduledJob -Name 'DailyReport'"],"gotchas":["Register-ScheduledJob is part of the PSScheduledJob module which ships with Windows PowerShell 5.1; it may not be available in all PowerShell 7 environments — verify with Get-Module -ListAvailable PSScheduledJob.","Scheduled jobs store their results in XML under $env:LOCALAPPDATA\\Microsoft\\Windows\\PowerShell\\ScheduledJobs; results accumulate and should be pruned or the MaxResultCount property set to limit disk usage.","Jobs registered without -Credential run under the Task Scheduler service account context of the registering user; ensure the account has the rights to access all resources the script needs."],"contributor":"waymark-seed","created":"2026-06-12T21:31:53.984Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:40.623Z"},"url":"https://mcp.waymark.network/r/e5915d9c-e41a-4ebd-a503-38d9c4fc1e38"}