Unistall Different Versions of Adobe

Hello All!
So quick rundown of what is going on here. I am trying to target specific versions of adobe to uninstall them remotely. What I think is happening is that the variable I created is not passing into my if else statements, or the variable is just seeing Adobe and not the version. Why I say that is because I am trying to target specific versions of Adobe.

Bellow is my code

New-PSDrive -Name "Q" -Root "\\someserver\string\of\folders\Adobe Reader\Acrobat Reader Classic 2020\Custom Deployment" 

###Checking version to unistall

$str_Version = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayVersion, Publisher | findstr Adobe
Write-Output $str_Version

If ($str_Version -eq "20.004.30006"){
    Write-Output "Removing Version 30006" $str_Version
    msiexec /x Q:\Adobe_Reader_2020_4.30006\AcroRead.msi /quiet
    Write-Output "Wrong Version going to next version."
   If ($str_Version -eq "20.005.30334 Adobe Systems Incorporated"){
    Write-Output "Removing Version 30334" $str_Version
    msiexec /x Q:\Adobe_Reader_2020_5.30334\AcroRead.msi /quiet
    Write-Output "Wrong Version going to next version."
   If ($str_Version -eq "20.005.30381"){
    Write-Output "Removing Version 30381" $str_Version
    msiexec /x Q:\Adobe_Reader_2020_5.30381\AcroRead.msi /quiet
    Write-Output "Wrong Version going to next version."
   If ($str_Version -eq "20.005.30407"){
    Write-Output "Removing Version 30407" $str_Version
    msiexec /x Q:\Adobe_Reader_2020_5.30407\AcroRead.msi /quiet
    Write-Output "Wrong Version going to next version."
   Start-Sleep -Seconds 30; 
   Remove-PSDrive -Name Q

Welcome to the forum. :wave:t4:

Before we proceed … please got back, edit your question and fix the formatting of your code …
When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

Regardless of that …

You’re mixing CMD commands or PowerShell aliasses with native PowerShell code - that’s a really bad idea and makes your code harder to read and harder to understand and to debug. I’d recommend to use as pure PowerShell code as possible.

When you compare version numbers you shoud cast them to the proper type. Otherwise the comparison uses string logic what might cause faulty results.

Instead of mapped network drives you may use UNC paths. And I’d recommend to copy the MSI files locally before you use them for installation or uninstallation.

Thank you for the help Olaf! Sorry this is my first time posting here. I hope the edited code better reflects more native PowerShell code. I just googled really quick how to map with PowerShell as opposed to cmd line. I am going this route as there will be computers that will be over the VPN and I figured it would be easier to do it this way as trying to copy half a gig over that connection. I could certainly exclude those computers and transfer the files over to the computers that directly connected.

As for the second part, what do you mean by cast them to the proper type?

Thank you in advance!

I am having a hard time understanding what you’re actually talking about. Sorry.

Instead of

You may do

$AdobeRegistryKey = 
Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* |
    Where-Object -Property DisplayName -match -Value Adobe

Now you have all possible information about the installed software. … like version:


… or like displayname


But all these properties are still strings.

Leading zeros are actually ignored when it comes to versioning. So this 20.005.30381 is actually the same like this 20.5.30381. But when you compare them as strings …

'20.005.30381' -eq '20.5.30381'

You get $false.
So you should cast the strings to the type [Version] to be able to compare them properly:

[Version]'20.005.30381' -eq [Version]'20.5.30381'

Usually you actually don’t have to transfer the installation files at all. In the


You have all you need. You just have to either extract the GUID of the MSI package and use it in your uninstall command or your simply change the /i to an /x and run it. :man_shrugging:t4:

Got it working! Thank you for your help!!