Here’s a little snippet of Powershell code I used recently to test some TSQL that runs according to a two week schedule.

This code will increment the date by one day, up to the maximum specified in $days , sleeping in between for a short while. The date is set back correctly at the end. Far from rocket science but it helps me test various bits of code in minutes instead of 2 weeks!

# Number of days to increment the date by
$days = 14;

for($counter=0; $counter -lt $days; $counter++)
{
	Set-Date (Get-Date).AddDays(1);
	# Sleep for 2 minutes so the code gets a chance to run
	Start-Sleep -Seconds 120;
}

# Set the date back correctly
Set-Date (Get-Date).AddDays(-$days);