A resource can be Present (required) or Absent (not needed) in the configuration. To subsequently cancel the configuration, you need to apply the new configuration. Script resources in DSC do not support the Ensure property, so to change the Script you need to create a modified script resource in the new AFAIK configuration.
The configuration should include TestScript , which returns false if 7zip is installed, and SetScript , which uninstalls the software. Pretty much the opposite of what you have now.
You can also change your configurations so that the Script resource downloads the msi file locally, and then has the package resource for its actual installation (or its removal), with DependsOn installed in the download script. This will be a cleaner configuration approach. The only difference between installing-config and uninstall-config is Ensure = Present vs Ensure = Absent in the Package resource, which installs / uninstalls msi.
In any case, you need to apply a new configuration, which would indicate that the software should not be installed.
If 7zip is only required during your configuration (to execute some other Script resources), perhaps you can do the following (unchecked):
configuration ExtractFolder { Script Download7zip { GetScript = { } SetScript = { #downloads msi locally } TestScript = { } } Package Install7zip { Ensure = "Present" Path = "c:\pathToMsi\7zip.msi" Name = "7Zip" ProductId = "ACDDCDAF-80C6-41E6-A1B9-8ABD8A05027E" #7zip prodid DependsOn = [Script]Download7zip } Script RunScript{ GetScript = { } SetScript = { #unpack some file using 7zip } TestScript = { } DependsOn = [Package]Install7zip } Package Uninstall7zip { Ensure = "Absent" Path = "c:\pathToMsi\7zip.msi" Name = "7Zip" ProductId = "ACDDCDAF-80C6-41E6-A1B9-8ABD8A05027E" #7zip prodid DependsOn = [Script]RunScript } }
If the above aprroach may be required, the ConfigurationMode settings should be set to ApplyOnly . Monitoring and automatic application are likely to be confused by two package resources that do the opposite.
source share