delete Google Chrome Cache in roaming profile

Welcome Forums General PowerShell Q&A delete Google Chrome Cache in roaming profile

Viewing 1 reply thread
  • Author
    Posts
    • #178506
      Participant
      Topics: 1
      Replies: 0
      Points: 15
      Rank: Member

      How to delete Google Chrome Cache in roaming profile on Virtual Desktops & stored path on server

      //Server/location\%username%/AppData\Roaming\Google\Chrome\User Data\Default\Code Cache\js

      and another location

      //virtualmachine/AppData\Roaming\Google\Chrome\User Data\Default\Code Cache\js This changes all the time with machine now. Could anyone help Thanks.

      I have done as below in a machine which works fine but unsure how it works for differnt laptopn number or pick all user name from a folder through "if"

      The one worked is

      $Now = Get-Date
      $Days = "30"
      $TargetFolder = "\\vmpvdb256\c$\Users\username\AppData\Roaming\Google\Chrome\User Data\Default\Code Cache\js\"
      $LastWrite = $Now.AddDays(-$Days)
      $Files = Get-Childitem $TargetFolder -Include $Extension -Recurse | Where {$_.LastWriteTime -le "$LastWrite"}
      foreach ($File in $Files) {
      if ($File -ne $NULL)
      {
      write-host "Deleting File $File" -ForegroundColor "Yellow"
      Remove-Item $File.FullName | out-null
      }
      else
      {
      Write-Host "Archive cleanup complete. No more files to delete!" -foregroundcolor "Green"
      }
      }

       

      Thanks.

      Wolfgang

    • #178587
      Participant
      Topics: 5
      Replies: 105
      Points: 264
      Helping Hand
      Rank: Contributor

      Hi,

      I'm not quite sure what you mean with the locations, but this should do the trick for all users on local machine. -Include needs to have * in the end of the path and I didn't get that to work, so I went to the slower path of checking the extensions in where statement.

      
      $Extension = "html","json"
      $Days = 30
      $TargetFolder = "C:\Users\*\AppData\Roaming\Google\Chrome\User Data\Default\Code Cache\js"
      Get-Childitem $TargetFolder -Recurse | Where {$_.LastWriteTime -le $(Get-Date).AddDays(-$Days) -and $Extension -contains $_.extension} | Remove-Item -Verbose
      
      
Viewing 1 reply thread
  • The topic ‘delete Google Chrome Cache in roaming profile’ is closed to new replies.