I’ve created a PowerScript file that is going to do some file cleaning up on my server. I want it to run every night at 11:30, so according to Microsoft’s technote I used the following syntax to register the job:
PS C:\> Register-ScheduledJob -Name "MyName" -FilePath "D:\Sites\Site\Tasks\DeleteUnusedGalleryImages.ps1" -Trigger @{Frequency="Daily"; At="11:30PM"}
There were no error messages, so I COULD assume it has been successfully registered. However, I do not know how the heck to list the jobs that are setup. I have used Get-Job but it returns nothing whatsoever, this would lead me to believe it hasn’t been registered, but if I run the same syntax to re-register the scheduled job I get the error message “already registered”.
So, my questions are:
- How do I get a list of the scheduled tasks on the server?
- How do I update the schedule of a job?
- How do I execute an existing job right now, instead of waiting? I’d like to check it works as a scheduled job (I’ve manually run the script to check it works)
Thanks guys – bit of a newbie to PowerShell but it seems awesome.
Thanks in advance
Al
you have to use Get-ScheduledJob not get-job
Normaly you can find you jobs in Task Scheduler Library\Microsoft\Windows\PowerShell\Scheduled Jobs.
Look here for more info : http://blogs.technet.com/b/heyscriptingguy/archive/2012/09/18/create-a-powershell-scheduled-job.aspx
and here : http://www.youtube.com/watch?v=RhRoofMOoI0 to see a presentation from PowerShell MVP Jeffery Hicks