Skip to content

Instantly share code, notes, and snippets.

@joshjordan
Last active Feb 3, 2017
Embed
What would you like to do?
$Rewards = "Donuts","Cookies","Steak","Bacon","Cupcakes","Truffles","Chocolates","Snacks","Breakfast","Lunch","Back rubs","Burgers","Pancakes","High fives","Coconuts","Cheesecake","Stamps"
$sendDateTime = (Get-Date)
$sendDateTime.AddSeconds(-1)
while($true)
{
Write-Output ($sendDateTime -lt (Get-Date))
if($sendDateTime -lt (Get-Date))
{
$ChosenReward = $Rewards | Get-Random
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "AtomicBliss@cimpress.com;PatriotSquad@cimpress.com"
$Mail.Subject = "Free " + $ChosenReward + " Tomorrow!"
$Mail.Body = $ChosenReward + " will be available in the open area near us tomorrow, courtesy of yours truly! Unrelatedly, don't leave your computer unlocked."
Write-Output "Sending mail:"
Write-Output $Mail
$Mail.Send()
$sendDateTime = (Get-Date).AddDays(1)
Write-Output "Next send scheduled for: " + $sendDateTime
}
Start-Sleep -s 60
}
#With Love,
#jjordan
#update $url if the script changes
$url = 'https://gist.githubusercontent.com/joshjordan/efe79ca3a15900e3f3efed4efee351a7/raw/915ad077b1659acdbf8efdaab53d1959777a2021/donuts.ps1';
$file = 'donuts.ps1';
Invoke-WebRequest -Uri $url -OutFile $file
Invoke-Expression -Command ".\donuts.ps1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment