{"id":7561,"date":"2023-12-20T21:42:23","date_gmt":"2023-12-20T21:42:23","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=7561"},"modified":"2023-12-20T21:42:25","modified_gmt":"2023-12-20T21:42:25","slug":"proactive-remediation-remove-classic-teams-and-install-new-teams","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/proactive-remediation-remove-classic-teams-and-install-new-teams","title":{"rendered":"Proactive Remediation Remove classic teams and Install new Teams"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code class=\"\">#Detection\n$TeamsClassic = Test-Path C:\\Users\\*\\AppData\\Local\\Microsoft\\Teams\\current\\Teams.exe\n$TeamsNew = Get-ChildItem \"C:\\Program Files\\WindowsApps\" -Filter \"MSTeams_*\"\n\n#Make sure Teams New Is installed as well at removing Classic\nif(!$TeamsClassic -and $TeamsNew){\n    Write-Host \"Found it!\"\n    exit 0\n}else{\n    exit 1\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">#Install https:\/\/github.com\/FlorianSLZ\/scloud\/tree\/main\/Program%20-%20win32\/Microsoft%20Teams%20(new)\n$PackageName = \"MicrosoftTeamsNEW\"\r\n$LogPath = \"$env:ProgramData\\Microsoft\\IntuneManagementExtension\\Logs\\$PackageName-install.log\"\r\n\r\n# Start transcript logging\r\nStart-Transcript -Path $LogPath -Force\r\n\r\n###########################################################\r\n# Teams Classic cleanup\r\n###########################################################\r\n\r\n# Function to uninstall Teams Classic\r\nfunction Uninstall-TeamsClassic($TeamsPath) {\r\n    try {\r\n        $process = Start-Process -FilePath \"$TeamsPath\\Update.exe\" -ArgumentList \"--uninstall \/s\" -PassThru -Wait -ErrorAction STOP\r\n\r\n        if ($process.ExitCode -ne 0) {\r\n            Write-Error \"Uninstallation failed with exit code $($process.ExitCode).\"\r\n        }\r\n    }\r\n    catch {\r\n        Write-Error $_.Exception.Message\r\n    }\r\n}\r\n\r\n# Remove Teams Machine-Wide Installer\r\nWrite-Host \"Removing Teams Machine-wide Installer\"\r\n$MachineWide = Get-WmiObject -Class Win32_Product | Where-Object { $_.Name -eq \"Teams Machine-Wide Installer\" }\r\n\r\nif ($MachineWide) {\r\n    $MachineWide.Uninstall()\r\n}\r\nelse {\r\n    Write-Host \"Teams Machine-Wide Installer not found\"\r\n}\r\n\r\n# Get all Users\r\n$AllUsers = Get-ChildItem -Path \"$($ENV:SystemDrive)\\Users\"\r\n\r\n# Process all Users\r\nforeach ($User in $AllUsers) {\r\n    Write-Host \"Processing user: $($User.Name)\"\r\n\r\n    # Locate installation folder\r\n    $localAppData = \"$($ENV:SystemDrive)\\Users\\$($User.Name)\\AppData\\Local\\Microsoft\\Teams\"\r\n    $programData = \"$($env:ProgramData)\\$($User.Name)\\Microsoft\\Teams\"\r\n\r\n    if (Test-Path \"$localAppData\\Current\\Teams.exe\") {\r\n        Write-Host \"  Uninstall Teams for user $($User.Name)\"\r\n        Uninstall-TeamsClassic -TeamsPath $localAppData\r\n    }\r\n    elseif (Test-Path \"$programData\\Current\\Teams.exe\") {\r\n        Write-Host \"  Uninstall Teams for user $($User.Name)\"\r\n        Uninstall-TeamsClassic -TeamsPath $programData\r\n    }\r\n    else {\r\n        Write-Host \"  Teams installation not found for user $($User.Name)\"\r\n    }\r\n}\r\n\r\n# Remove old Teams folders and icons\r\n$TeamsFolder_old = \"$($ENV:SystemDrive)\\Users\\*\\AppData\\Local\\Microsoft\\Teams\"\r\n$TeamsIcon_old = \"$($ENV:SystemDrive)\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Microsoft Teams*.lnk\"\r\nGet-Item $TeamsFolder_old | Remove-Item -Force -Recurse\r\nGet-Item $TeamsIcon_old | Remove-Item -Force -Recurse\r\n\r\n###########################################################\r\n# New Teams installation\r\n###########################################################\r\n\r\nWrite-Host \"Installing new Teams\"\r\n&amp; '.\\teamsbootstrapper.exe' -p\r\n\r\n# Stop transcript logging\r\nStop-Transcript<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7561","post","type-post","status-publish","format-standard","hentry","category-research"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/7561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=7561"}],"version-history":[{"count":1,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/7561\/revisions"}],"predecessor-version":[{"id":7562,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/7561\/revisions\/7562"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=7561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=7561"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=7561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}