Need help - Unable to uninstall app through Powershell/Intune

Alim 6 Reputation points
2022-06-09T11:06:13.143+00:00

Hi All,

I'm having some trouble with deploying a powershell script through our InTune enviroment. The script is set to uninstall the "Dell Command | Update" windows app but seems to be failing. I've checked the logs and can see it ran successfully. I also added a write-output to the C:\Temp folder so I knew it ran correctly.
Here is the script.

Set-ExecutionPolicy Bypass -scope Process -Force  
  
if (Get-AppxPackage DellInc.DellCommandUpdate) {  
Get-AppxPackage DellInc.DellCommandUpdate | Remove-AppxPackage  
}  
else {  
}  
  
if (Get-AppxPackage DellInc.DellUpdate) {  
Get-AppxPackage DellInc.DellUpdate | Remove-AppxPackage  
}  
else {  
}  
write-output "Script worked" | out-file c:\temp\outputDCU.txt  

Here is the success message
209863-image.png

But the items still remains
209864-image.png

If I run the script locally though the machine is works fine, it's just via InTune it seems to be failing.

Any help here would be highly appriciated.

Thanks in advance :)
Alim

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,381 questions
Microsoft Intune Configuration
Microsoft Intune Configuration
Microsoft Intune: A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.Configuration: The process of arranging or setting up computer systems, hardware, or software.
1,729 questions
Microsoft Intune
Microsoft Intune
A Microsoft cloud-based management solution that offers mobile device management, mobile application management, and PC management capabilities.
4,365 questions
0 comments No comments
{count} vote

2 answers

Sort by: Most helpful
  1. Rufer Kaspar 1 Reputation point
    2022-06-09T19:59:34.347+00:00

    I have the same problem with uninstalling apps via powershell script in Intune.

    In win32 app configuration I use
    powershell.exe -executionpolicy bypass .\uninstall.ps1

    the uninstall script contains nothing fancy, mostly like
    Get-Process 7zFM* | Stop-Process -Force -ErrorAction SilentlyContinue
    Start-Process "$env:ProgramFiles\7-Zip\uninstall.exe" -ArgumentList "/S" -wait

    All scripts works fine when I run them on the machine itself, but not via Intune.
    Installing a win32 app with the comandline mentioned above also works (the installscript is basicly the same and contains Start-Process "$PSScriptRoot\7z-setup.exe" -argumentlist "/S" -wait)


  2. Lu Dai-MSFT 28,356 Reputation points
    2022-06-10T02:21:43.713+00:00

    @Alim Thanks for posting in our Q&A.

    To clarify this issue, we appreciate your help to collect some information:

    1. Please make sure that the device has met the prerequisites.
      https://learn.microsoft.com/en-us/mem/intune/apps/intune-management-extension#prerequisites
    2. Please try to set "Run this script using the logged on credentials" to "No". If the device is 64 bit, please set "Run script in 64 bit PowerShell Host" to "Yes".
    3. Please check if it shows success in Devices > Scripts > select the target script > Device/User status.
    4. Please reboot Intune management extension agent or restart the device. And then check if it works.

    If there is anything update, feel free to let us know.


    If the answer is the right solution, 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.