Skip to content

Instantly share code, notes, and snippets.

@WimObiwan
Created January 21, 2019 14:51
Show Gist options
  • Save WimObiwan/488f5ad8ea5a88f55255621ca4144173 to your computer and use it in GitHub Desktop.
Save WimObiwan/488f5ad8ea5a88f55255621ca4144173 to your computer and use it in GitHub Desktop.
ScheduledJob
$command = 'C:\SQLBackups\DoBackup.ps1'
# trigger hourly
$trigger = New-JobTrigger -Once -At '2015-01-01' -RepetitionInterval (New-TimeSpan -Hour 1) -RepetitionDuration ([TimeSpan]::MaxValue)
$cred = Get-Credential
Register-ScheduledJob -FilePath $command -Name SQLBackup -Trigger $trigger -Credential $cred
# Troubleshooting
Get-Job
Receive-Job -Keep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment