Advertisement
toshoyan

Untitled

Feb 16th, 2024
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param([string] $username="")  
  2.  
  3. if(Test-Path -Path C:\Users\$username\AppData\Local\Google\Chrome\User` Data\Default\Cache)  
  4.  
  5. {  
  6.  
  7.    $itemsCountBefore = Get-ChildItem -Path C:\Users\$username\AppData\Local\Google\Chrome\User` Data\Default\Cache -Recurse | Measure-Object | %{$_.Count}
  8.  
  9.    Remove-Item -Path C:\Users\$username\AppData\Local\Google\Chrome\User` Data\Default\Cache -Recurse -Force  
  10.  
  11.    $itemsCountAfter = Get-ChildItem -Path C:\Users\$username\AppData\Local\Google\Chrome\User` Data\Default\Cache -Recurse | Measure-Object | %{$_.Count}
  12.  
  13.    if($itemsCountBefore -gt $itemsCountAfter)
  14.  
  15.    {
  16.  
  17.       Write-host "Cache cleared for Google Chrome"
  18.  
  19.    }
  20.  
  21.    else
  22.  
  23.    {
  24.  
  25.       Write-Host "Failed to clear cache for Google Chrome"
  26.  
  27.    }
  28.  
  29. }  
  30.  
  31. else  
  32.  
  33. {  
  34.  
  35.    Write-host "Specified path doesn't exist."  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement