Here’s one way to fake a schedule using jobs with the Start-Sleep cmdlet. Let’s say I want to start a job at 19:43:00. You could probably pass dates as well, though. Just place your script name/commands instead of the “Executed!” string.


PS U:\bin> Start-Job -Name USCase98765 -ScriptBlock {Start-Sleep -Seconds ([int]((New-TimeSpan -Start (Get-Date) -End (Get-Date -Hour 19 -Minute 43 -Second 0)).TotalSeconds)); `
(Get-Date);"Executed!"}


Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
3 USCase98765 Running True localhost Start-Sleep -Seconds (...
PS U:\bin> Receive-Job -Name USCase98765
Thursday, October 28, 2010 7:43:00 PM
Executed!