try {
$TeamsApp = Get-AppxPackage "*Teams*" -AllUsers -ErrorAction SilentlyContinue
if ($TeamsApp.Name -eq "MicrosoftTeams")
{
Write-Host "Built-in Teams Chat App Detected"
Exit 1
}
ELSE
{
Write-Host "Built-in Teams Chat App Not Detected"
Exit 0
}
}
catch {
$errMsg = $_.Exception.Message
return $errMsg
Exit 1
}
try
{
$detecta = Get-AppxPackage | select * | where-object {$_ -like "*MicrosoftTeams*"}
if ($detecta) {
"removing $($detecta.Name)"
Remove-AppxPackage -AllUsers -Package $detecta.PackageFullName
echo "removed" | out-file removed.txt
exit 0
} else {
"do nothing"
exit 0
}
}
catch{
$errMsg = $_.Exception.Message
Write-Error $errMsg
exit 1
}