Update – 28 November 2022 – Check out this blog for a better way to remove the Windows 11 built in Teams app
In my last blog post, I wrote about using Win32 Apps as a better alternative to the Intune PowerShell feature for configuration changes. I also recently wrote about how to remove the new built-in Microsoft Teams app.
My friend Loryan Strant (Check out his awesome wisdom here) reached out and mentioned that he has seen some occurrences of the built-in Teams app reappearing some time after the PowerShell Script has been run to remove the App.
So taking my learnings from using the Win32 App approach, I though this method may be a good way to tackle the issue of the app reappearing.
The script used by the Intune PowerShell feature to remove the built-in Teams App can be reused as the Uninstall command for the Win32 App
Get-AppxPackage "*Teams*" -AllUsers | Remove-AppPackage –AllUsers
Now this is where things get a little bit different from what normally happens. The Win32 App needs an Install command, but we are not going to use the app to install anything as the sole purpose of this Win32 App is to remove the built-in Teams App
So the the install script can be a simple Write-Host command and nothing else.
Write-Host "This Script does nothing, zip, nada... nothing at all to see here"
The last requirement is a detection script.
$TeamsApp = Get-AppxPackage "*Teams*" -AllUsers -ErrorAction SilentlyContinue
if ($TeamsApp.Name -eq "MicrosoftTeams")
{
Write-Output "Teams Built-in Present"
Exit 0
}
ELSE
{
Write-Output "Teams Built-in Not Present"
Exit 1603
}
To create the Win32 App you will need the Microsoft Win32 Content Prep Tool
Place all of the required scripts into a single folder

From a Terminal Window, run the IntuneWinAppUtil.exe
Specify the source folder, the setup file and the output folder.

The utility will then create a .intunewin file which can be uploaded to Intune.

Ensure the app information has the appropriate detail

Use the following Install and Uninstall commands:
powershell -executionpolicy bypass -file Install-TeamsBuiltIn.ps1
powershell -executionpolicy bypass -file Uninstall-TeamsBuiltIn.ps1

Add in the requirements that are appropriate to your environment

Use the detection script created earlier

Again, this is where things are little bit different. Instead of deploying this App as a Required assignment, deploy it as an Uninstall assignment.
I have chosen to use my Dynamic Device Azure AD group containing all of my Managed Windows devices using an Intune Filter Windows 11 Devices.

On my test device, I can now see that the built-in Teams App has (again) been removed.


If the application does ever reappear on the device, Intune will pick up this up within the 8 hour data inventiry cycle, and the Installaton status the Microsoft Teams – Built in App will change to Installed.
Because this App has a Resolved intent of Uninstall, the uninstall command will run and the application will automatically be removed.
P.
hello, thanks for the tutorial, but i didn’t understand where to upload the PS1 uninstall script in Intune?
So that the command can run it at all. Thank you for the advice!
LikeLike
Hello Petr,
Sorry for the delay responding – As long as you have both scripts in the same directory when using the Intine wrapping tool, they will both be contained in the .intunewin file. You just need to specify the uninstall script in the uninstall field. Let me know how it goes for you and feel free to message me if you need more assistance.
Paul
LikeLike
In the uninstall command, is it Remove-AppPackage or Remove-AppXPackage ?
LikeLike
Hi – The command is Remove-AppPackage. However, I’ve since switched from this approach to using Proactive Remediation in Intune. Let me know if you want me to do a writeup on that.
LikeLike
Hello Paul,
Please can you post a writeup on how to do this with Proactive Remediation?
LikeLike
Hi Thomas – Will do mate.
LikeLike
Hi Thomas – Blog for removing Built in Teams with proactive remediation is here – https://thenewnumber2.com/2022/11/28/intune-proactive-remediation/
LikeLike
Hi Paul, thanks for the guide. I don’t understand one thing. We put this command in Uninstall command: “powershell -executionpolicy bypass -file Uninstall-TeamsBuiltIn.ps1”. How will it get the information from file “uninstall-teamsBuiltin.ps1” since we didn’t upload that script anywhere. I followed the above steps, but it failed.
LikeLike
Hi Asad,
Have you created the PowerShell script and wrapped it using the W32 Content Prep Tool?
I’ll be blogging on using Proactive Remediation for removing this app very soon, which I have found to be a much better way to do this. Will try and get that blog out in the next few days
P.
LikeLike
I followed your steps, did not work on Win11 [64bit].
LikeLike
Hi Solomon, Have a look at https://thenewnumber2.com/2022/11/28/intune-proactive-remediation/ and let me know if this works for you?
LikeLike