This PowerShell script checks for updates to installed Chocolatey packages and upgrades them if a newer version is available.
- PowerShell 5.1 or later
- Chocolatey
The script performs the following tasks:
- Retrieves the local and remote versions of installed Chocolatey packages.
- Splits the version strings into components (Major, Minor, Hotfix, Build).
- Compares the local and remote versions to determine if an upgrade is required.
- Upgrades the package if a newer version is available.
- Logs the results of the upgrade process.
Retrieves the package version from the remote or local repository.
Parameters:
Package
(string): Name of the Chocolatey package.Local
(switch): Switch to get the local package version.Remote
(switch): Switch to get the remote package version.
Splits the version string into components.
Parameters:
Version
(string): Version string to split.
Tests if an upgrade is required by comparing version components.
Parameters:
Local
(hashtable): Hashtable containing local version components.Remote
(hashtable): Hashtable containing remote version components.Package
(string): Name of the Chocolatey package.
- Open PowerShell
- Run the script:
.\Update-ChocoPackages.ps1
NOTE:
If you have installed packages with elevated admin privileges, you must run this script with administrator privileges.