How to remove apps from user context and deploy this script via Intune.

TZ 46 Reputation points
2023-07-20T17:47:21.36+00:00

Hi everyone,

I was trying to remove some apps such as Chrome/Firefox/Zoom and others from many computers in my organization.

These apps were installed manually by the user without admin rights(User Context), I was trying to create a script to remove these apps but it does not work. My intention is to remove all apps installed with no permission, this script will need to be deployed via Intune.

Has anyone got any idea how can I achieve it?

Thanks

T

function Uninstall-Win32App {
    param([string]$appName)
    $uninstallString = Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*" |
        Where-Object { $_.DisplayName -like "*$appName*" } |
        Select-Object -ExpandProperty UninstallString

    if ($uninstallString) {
        Write-Output "Uninstalling $appName..."
        Start-Process -FilePath "msiexec.exe" -ArgumentList "/x $uninstallString /quiet" -Wait
    } else {
        Write-Output "$appName not found."
    }
}

# Uninstall Zoom (Win32 application)
Uninstall-Win32App -appName "Zoom"

# Uninstall Chrome (Win32 application)
Uninstall-Win32App -appName "Google Chrome"

# Uninstall Firefox (Win32 application)
Uninstall-Win32App -appName "Mozilla Firefox"


Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,508 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,185 questions
{count} votes

Accepted answer
  1. Crystal-MSFT 44,506 Reputation points Microsoft Vendor
    2023-07-26T02:14:21.7933333+00:00

    @TZ, Thanks for the update and sharing. I am glad that the apps can removed successfully. To help others find the method, please let me write a summary:

    Issue:

    How to remove apps from user context via Intune.

    Resolution:

    User's image

    User's image

    User's image

    User's image

    User's image

    Thanks for your time and have a nice day!


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. TZ 46 Reputation points
    2023-07-20T20:54:24.6566667+00:00

    I spent a couple of hours trying to run it, but couldn't make it work. Not sure if it is the best way to remove apps on user context. What would you do?

    0 comments No comments

  2. Crystal-MSFT 44,506 Reputation points Microsoft Vendor
    2023-07-21T02:05:20.5933333+00:00

    @TZ , Thanks for posting in Q&A. For the PowerShell script, could you let us know how did we configure the setting "Run this script using the logged on credential"? Based as I know, when it sets as Yes, it uses logged on user credential to run the script. But if the user does not have local administrator permission. I think it will fail to remove the registry key. If it sets to no, the PowerShell script will run under system account which means the registry key related with is system account instead of the user.

    https://learn.microsoft.com/en-us/mem/intune/apps/intune-management-extension

    Hope the above information can help.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  3. Pavel yannara Mirochnitchenko 12,296 Reputation points MVP
    2023-07-21T05:46:00.2333333+00:00

    Actually you can run stuff like this "Start-Process -FilePath "msiexec.exe" -ArgumentList "/x {msiproductcode} /quiet" -Wait" without minding, is the app there or not but it will remove all Chromes or Firefoxes, whenever they are installed in User Context or System Context. If you still need Firefox to be placed on users computer in system context, you can just create a Win32 app with Firefox and specify more detailed detection method maybe even with file version numbering, then you will get the right app you want. This approach will result, that end users will be left out of Firefox for a moment.


  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more