Remove-MSIApplications function RegEx issue

//Remove-MSIApplications function RegEx issue
Remove-MSIApplications function RegEx issue2018-01-19T15:35:42+00:00

The Toolkit Forums General Remove-MSIApplications function RegEx issue

  • Author
    Posts
  • Justin
    Participant
    Post count: 2

    Hey everyone,

    My PowerShell experience is limited, so bear with me a little bit here. I’m trying to create a package for Adobe Acrobat DC 2017 Classic 17.011.30070. During the pre-installation step, I want to uninstall all previous versions of Adobe Acrobat. Normally, I’d just use Remove-MSIApplications -Name 'Adobe Acrobat', but Adobe, in their infinite bleeping wisdom, names the equivalent version of Adobe Reader “Adobe Acrobat Reader blah blah blah”.

    So I created a simple RegEx to avoid matching Adobe Reader installations. Here’s the code I’m trying to use:
    Remove-MSIApplications -Name 'Adobe' -FilterApplication (,('DisplayName', 'Adobe\sAcrobat\s(?!Reader)', 'RegEx'))

    I know this RegEx works outside of the App Deploy Toolkit, but it doens’t match anything when using it inside of the toolkit. So I dug into “AppDeployToolkitMain.ps1” and discovered this:
    If ($installedApplication.($Filter[0]) -match [regex]::Escape($Filter[1])) {
    Doesn’t [regex]::Escape() tell PowerShell to ignore regex in the string inside the parenthesis? So this would effectively neutralize any RegEx I’m trying to pass. Is this a bug or are regular expressions just not supported here? Is there a better way to accomplish what I’m trying to do?

    I suppose I could just put my own code in the pre-installation phase, but I trust the toolkit a little more than I trust myself. This is the code I would have used in my own scripts:
    Get-Package | Where-Object {$_.Name -match "Adobe\sAcrobat\s(?!Reader)"} | Foreach-Object {Uninstall-Package -Name $_.Name -Force}

    I appreciate any responses, thanks!

  • Justin
    Participant
    Post count: 2

    I should have looked – There’s an open bug for this on GitHub. My bad!

    https://github.com/PSAppDeployToolkit/PSAppDeployToolkit/issues/317

You must be logged in to reply to this topic.