ExcludeFromUninstall Help

//ExcludeFromUninstall Help
ExcludeFromUninstall Help 2016-01-26T21:37:56+00:00

The Toolkit Forums General ExcludeFromUninstall Help

  • Author
  • Brian
    Post count: 42
    #1044 |

    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(TM) 6 Update 31','Exact'),@('DisplayName','Java 7 Update 55','Exact'))

    Any input is appreciated. Thank you.

  • Muhammad Mashwani
    Post count: 118

    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.

  • Carl
    Post count: 1

    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(TM) 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.

    • This reply was modified 1 year, 10 months ago by  Carl. Reason: Couldn't get the HTML to work so removed it to make it more readable
    • This reply was modified 1 year, 10 months ago by  Carl. Reason: A preview button would be helpful

You must be logged in to reply to this topic.