Skip to content

Instantly share code, notes, and snippets.

@PSingletary
Created June 4, 2020 01:35
Show Gist options
  • Select an option

  • Save PSingletary/8b726a98df128fba3989bb4f2b11aef3 to your computer and use it in GitHub Desktop.

Select an option

Save PSingletary/8b726a98df128fba3989bb4f2b11aef3 to your computer and use it in GitHub Desktop.
#Define RegEx filter to match folder names
$FoldersToRemove = “(cache|storage|database|blob|IndexedDB|tmp)”
#Get folders within Teams AppData area
$Folders = Get-ChildItem “C:\Users\$($_.Name)\AppData\Roaming\Microsoft\Teams”
#Switch statement checks the folder names and removes if found to match what is in $FoldersToRemove
switch -RegEx ($Folders.Name) {
$FoldersToRemove {Remove-Item $_.FullName -Recurse -Force}
@PSingletary
Copy link
Author

or
$usersList = Get-ChildItem ‘HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList’ | % {Get-ItemProperty $.pspath } | ? {$.profileImagePath -like 'C:\users*'} | Select *

$folderArray = @(‘folder1’,’folder2’)

$usersList | % {
$user_item = $_
#Code here to deal with user profiles found
$user_item

$folderArray | % {
“Deleting C:\users\$($user_item.profileImagePath)\$_”
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment