Need to Remove Microsoft Teams (personal) only

Hi All,

I want to uninstall MS Teams (personal) through BigFix. when I tried to uninstall manually it successfully uninstalled from machine, but when I try to uninstall through BigFix, Action got completed with exit code=0 but it was not removed. please find the command which I used for the uninstallation and help me to how it will run through BigFix.

// Define the log file path
$logFilePath = “C:\Windows\Temp\MSTeamsPersonalRemoved.log”
$logFilePathNotFound = “C:\Windows\Temp\MSTeamsPersonalNotFound.log”
Remove-Item -Path $logFilePath -Force
Remove-Item -Path $logFilePathNotFound -Force

//Get the package family name for Microsoft Teams with “bbwe”
$teamsPackage = Get-AppxPackage | Where-Object { $_.PackageFamilyName -like “MicrosoftTeams_8wekyb3d8bbwe” }

// Check if the package is found
if ($teamsPackage) {
# Uninstall the package using the PackageFullName
$packageFullName = $teamsPackage.PackageFullName
$packageFullName
Remove-AppxPackage -Package $packageFullName
Write-Host “Microsoft Teams personal app has been uninstalled successfully.”
New-Item -Path $logFilePath -ItemType File
} else {
Write-Host “Microsoft Teams personal app is not found on this system.”
New-Item -Path $logFilePathNotFound -ItemType File
}

Also, I have created one .ps1 file with the above-mentioned command and run thru BigFix with below command.
waithidden powershell.exe -ExecutionPolicy Bypass “__Download\MSTeamApp Removal.ps1”

That could be because an current user session is necessary to delete it; try changing the following in the script and see what happens.

override wait
hidden=true
runas=currentuser
wait powershell.exe -ExecutionPolicy Bypass “__Download\MSTeamApp Removal.ps1”

Also found my older post: