# Uninstalling programs in windows that are less than X version

Hi puppeters,

I am working on some puppet manifests to manage windows machines, and so , for a while I was installing 7zip -for example- using this method:

package { '7-Zip 9.20 (x64 edition)': - ensure => installed, - source => 'http://downloads.sourceforge.net/sevenzip/7z920-x64.msi', - provider => 'windows' - }

Now I have changed that, so chocolatey will be managing this install . -The thing here- is; I want to change my puppet manifest to remove the 7zip old version (no matter what old version is that, because I am managing a big number of machines), I thought to try matching with a regex any package that has a version less than ‘7zip 16.02.0.20160811' but that turned up too complicated , is there any way i can achieve the same goal with less effort , (Also I know that i can do the same with a batch file), but i want a more cleaner solution to that.

edit retag close merge delete

Sort by » oldest newest most voted

You should be able to specify the MSI PackageCode as the title of the resource:

package { '<package code>':
ensure => absent,
source => '...',
provider => windows
}


See https://docs.puppet.com/puppet/4.7/re...packagewindows.html#known-issues-prior-to-puppet-34--pe-32 for info about how to get the package code for a given MSI.

more

This is definitely one way to do it!

( 2016-10-07 13:05:14 -0600 )edit

One option is the one that joshc mentioned. Another is that Chocolatey is moving towards supporting the ability to uninstall software it doesn't manage as packages (licensed versions). This is something you will be able to take advantage of in Puppet manifests with a simple switch in the uninstall_options.

more