We recently had a client that removed Microsoft teams from a server and they wanted all of the residue from each user profile deleted. A quick check showed that there was three folders under each user that we needed to delete in order to reclaim the space on the server and maintain good digital hygiene.
The problem was this server had dozens of user profiles on it and we did not want to delete these folders one by one, so we wrote this simple PowerShell script, we thought you might also have a use for:
# Delete Files and Folders from Every User Profile
# URTech.ca July 2024 - Use at own risk
Get-ChildItem -Path "C:\Users" | ForEach-Object {
# Delete the Teams and TeamsPrsenseAddin directories if they exist and print a message
Remove-Item -Path "$($_.FullName)\AppData\Local\Microsoft\Teams" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
if (!$?) { Write-Host "Deleted Teams directory for user $($_.Name)" }
Remove-Item -Path "$($_.FullName)\AppData\Local\Microsoft\TeamsPresenceAddin" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
if (!$?) { Write-Host "Deleted TeamsPresenceAddin directory for user $($_.Name)" }
Remove-Item -Path "$($_.FullName)\AppData\Local\Microsoft\TeamsMeetingAddin" -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
if (!$?) { Write-Host "Deleted TeamsMeetingAddin Addin directory for user $($_.Name)" }
}
This website uses cookies.