ExcludeFromUninstall Help

This command works successfully in that it does not uninstall Java 7u55
Remove-MSIApplications -Name "Java*" -Wildcard -ExcludeFromUninstall @(,@('DisplayName','Java 7 Update 55','Exact'))

While this command uninstall all versions of Java
Remove-MSIApplications -Name "Java*" -Wildcard -ExcludeFromUninstall @(@('DisplayName','Java™ 6 Update 31','Exact'),@('DisplayName','Java 7 Update 55','Exact'))

Any input is appreciated. Thank you.

What does the log file say when you run the command? That will give use some more details on how the function processed the command.

I’ve had a similar issue recently and think that there is an error in the syntax provided in the documentation. I believe that when specifying an array of arrays you have to use the comma operator rather than @().

The issue comes on line 2508 in version 3.6.8 of the toolkit, which looks like this:
If (($null -ne $ExcludeFromUninstall) -and ($ExcludeFromUninstall.Count)) {
ForEach ($Exclude in $ExcludeFromUninstall) {
If ($Exclude[0][2] -eq 'RegEx') {

The $Exclude[0][2] is returning the 3rd character of the first string in the array, so it never equates to being true. In the example posted above it would return ‘s’.

I believe that the correct way to specify the arrays to get this to work would be
Remove-MSIApplications -Name “Java*” -Wildcard -ExcludeFromUninstall @(,
(‘DisplayName’,‘Java™ 6 Update 31’,‘Exact’),
(‘DisplayName’,‘Java 7 Update 55’,‘Exact’))

Note the comma after @( and the double comma after the first array. I don’t believe that you need the multiple @ either (line breaks put in to make it more readable.

I could very well be wrong, but it appears to be working as expected after making these changes in my script.