From 6604aa08467f96bb7bcecbec512a3527d6814b18 Mon Sep 17 00:00:00 2001 From: austinmroczek Date: Sat, 10 Sep 2016 19:37:54 -0700 Subject: [PATCH] create scheduled task for upgrades --- utils/install-basic-software.ps1 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/utils/install-basic-software.ps1 b/utils/install-basic-software.ps1 index 8257d2d..a7341bd 100644 --- a/utils/install-basic-software.ps1 +++ b/utils/install-basic-software.ps1 @@ -32,6 +32,14 @@ $packages = @( echo "Setting up Chocolatey software package manager" Get-PackageProvider -Name chocolatey -Force +echo "Creating daily task to automatically upgrade Chocolatey packages" +# adapted from https://blogs.technet.microsoft.com/heyscriptingguy/2013/11/23/using-scheduled-tasks-and-scheduled-jobs-in-powershell/ +$taskName = "Chocolatey Daily Upgrade" +$taskAction = New-ScheduledTaskAction –Execute C:\programdata\chocolatey\choco.exe -Argument "upgrade all -y" +$taskTrigger = New-ScheduledTaskTrigger -At 2am -Daily +$taskUser = "Admin" +Register-ScheduledTask –TaskName $taskName -Action $taskAction –Trigger $taskTrigger -User $taskUser + echo "Installing Packages" Install-Package -Name $packages -Force -ProviderName chocolatey