Execute-ProcessAsUser and Remove-MSIApplication

I’m looking to Uninstall user-based installs of Remote Desktop when running PSADT as System.
We have different versions installed and I would like to remove which ever version they have.

Is there any way I can combine these below so that it runs for the logged in user?

Execute-ProcessAsUser and Remove-MSIApplications -Name ‘Microsoft Remote Desktop’

Execute-ProcessAsUser needs for the affected user would have to be logged on AT EXECUTION TIME for your solution to work.
If the same computer has multiple users with Microsoft Remote Desktop installed in their profile, Execute-ProcessAsUser will only fix one user profile.

These packages are deployed when the User is logged in via Intune so that’s not a problem :slight_smile:

Is there any way to do this?

Can I use something along these lines to detect the Uninstall String for the remote desktop package?

 $RemoteDesktop = ((Get-InstalledApplication -Name ‘Remote Desktop’).UninstallString -split ‘" ‘).Trim(’"’)

 Execute-ProcessAsUser -Path "C:\Windows\System32\MsiExec.exe" -Parameters "/X $RemoteDesktop"

UninstallString includes MsiExec.exe and possibly parameter that will make the uninstall interactive.

Use ProductCode instead:

$RemoteDesktopProdCode = (Get-InstalledApplication -Name ‘Remote Desktop’).ProductCode

Execute-ProcessAsUser -Path "C:\Windows\System32\MsiExec.exe" -Parameters "/X $RemoteDesktopProdCode"

Caveat: I don’t have a Windows box with an PS editor so I cannot be sure of the syntax.

1 Like

That worked!!! You my friend are a legend!!!

Thank you so much! This website is super helpful while I’m learning PSADT :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.