Forum Discussion
AB21805
Jan 24, 2024Bronze Contributor
Issue with Intune Script: Successful Report, but Ineffective Removal of Personal Teams on Windows 11
Hello everyone,
I've encountered an issue with a script that performs flawlessly when executed manually on the device. However, when running the same script via Intune, it reports success but doesn't effectively achieve its goal. Despite restarting the device, the problem persists. The script is designed to remove personal Teams on Windows 11 devices. Any insights or assistance in resolving this discrepancy would be greatly appreciated. What do I need to to the script to get it to work
Here is the script:
$MSTeams = "MicrosoftTeams"
$WinPackage = Get-AppxPackage | Where-Object {$_.Name -eq $MSTeams}
$ProvisionedPackage = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq $WinPackage }
If ($null -ne $WinPackage)
{
Remove-AppxPackage -Package $WinPackage.PackageFullName
}
If ($null -ne $ProvisionedPackage)
{
Remove-AppxProvisionedPackage -online -Packagename $ProvisionedPackage.Packagename
}
$WinPackageCheck = Get-AppxPackage | Where-Object {$_.Name -eq $MSTeams}
$ProvisionedPackageCheck = Get-AppxProvisionedPackage -Online | Where-Object { $_.DisplayName -eq $WinPackage }
If (($WinPackageCheck) -or ($ProvisionedPackageCheck))
{
throw
}
- Found a fix : #Kill Teams Personal EXE if running
TASKKILL /IM msteams.exe /f
#Remove it
Get-AppxPackage MicrosoftTeams -allusers | Remove-AppxPackage -allusers
Exit 0
- AB21805Bronze ContributorFound a fix : #Kill Teams Personal EXE if running
TASKKILL /IM msteams.exe /f
#Remove it
Get-AppxPackage MicrosoftTeams -allusers | Remove-AppxPackage -allusers
Exit 0