Create a Scheduled Task to keep all Chocolatey Packages up-to-date

Rebuilding your PC is always a drag, even with useful utilities like Ninite.

I recently created a PowerShell DSC script that I can use whenever I need to rebuild my PC. As part of that, I used the cChoco provider to automatically install applications using Chocolatey. I’ll be writing a blog post with more details shortly.

That’s a great way to get the applications installed, but not for keeping them up-to-date. Chocolatey allows you to run ‘choco upgrade all’ manually to do this:

Command prompt window showing the results of a 'choco upgrade all -y' command

Rather than manually create the scheduled task to automate this, I created this short PowerShell script:

The script will:

  1. Locate the choco.exe binary (It’ll quit if it can’t find it in the path)
  2. Set up a scheduled task that runs said binary at system startup

Note that this script will only work on Windows 8 and newer machines, because it relies on the *-ScheduledTask cmdlets.

4 thoughts on “Create a Scheduled Task to keep all Chocolatey Packages up-to-date

  1. We will probably need to pull in cChoco into Chocolatey namespace on Github like we have the other providers. My understanding is that it is good, but it needs some more things to make it more complete.

    Like

  2. Nice script. Since I work with mobile devices a lot, I’ve added two options to $taskSettings in my own variant of your script:
    -RunOnlyIfNetworkAvailable: no upgrade info will be available if there is no network connection
    – AllowStartIfOnBatteries: This defaults to ‘no’ for scheduled tasks, so if you want tasks to run while working on battery power, explicitly add this option.

    Like

    • Thanks Marcus. I haven’t used this script since I originally created it because I moved to a new job that had a Windows 7 fleet. Looking forward to dusting it off again in a few months when I move us onto Windows 10.

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s