7

I'm writing a set of PS scripts to help set up and maintain a Windows dev environment. Right now, I am maintaining two script files, one for installing Chocolatey packages, and another for upgrading the same packages.

The two scripts are very straightforward, they look more or less like this:

# choco-install.ps1
choco install git
choco install VisualStudioCode
# ...
# choco-upgrade.ps1
choco upgrade git
choco upgrade VisualStudioCode
# ...

I'd like to merge these into a single script that, for each package, will install it if it's not installed, and upgrade the package if it is installed already. I'd like to be able to share these scripts, therefore they must not interfere with other Chocolatey packages that a user might have installed.

Is there a built-in chocolatey command to accomplish this, or another powershell trick I could use?

1

1 Answer 1

11

Running choco upgrade will install the package if it isn't already installed.

https://chocolatey.org/docs/commandsupgrade

1
  • I came to this link to mention that. Commented Dec 18, 2017 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .