Powershell无法清除IE浏览Cookie,缓存等

我正在尝试从默认位置 C:\ Users \\ AppData \ Local \ microsoft \ Windows \ INetCache 清除浏览器数据。我正在尝试清除该路径中的Cookies,缓存或任何类型的文件,但不确定在这里缺少什么

screenshot

Write-Host -ForegroundColor yellow "#######################################################"
""
Write-Host -ForegroundColor Green "Powershell commands to delete cache & cookies in Firefox,Chrome & IE browsers"
Write-Host -ForegroundColor Green "By Cesar Silva"
Write-Host -ForegroundColor Green "VERSION: 3"
""
Write-Host -ForegroundColor yellow "#######################################################"
""
Write-Host -ForegroundColor Green "CHANGE_LOG:
v2.4: - Resolved *.default issue,issue was with the file path name not with *.default,but issue resolved
v2.3: - Added Cache2 to Mozilla directories but found that *.default is not working
v2.2: - Added Cyan colour to verbose output
v2.1: - Added the location 'C:\Windows\Temp\*' and 'C:\`$recycle.bin\'
v2:   - Changed the retrieval of user list to dir the c:\users folder and export to csv
v1:   - Compiled script"
""
Write-Host -ForegroundColor yellow "#######################################################"
""
#########################
"-------------------"
Write-Host -ForegroundColor Green "SECTION 1: Getting the list of users"
"-------------------"
# Write Information to the screen
Write-Host -ForegroundColor yellow "Exporting the list of users to c:\users\%username%\users.csv"
# List the users in c:\users and export to the local profile for calling later
dir C:\Users | select Name | Export-Csv -Path C:\users\$env:username\users.csv -notypeInformation
$list=Test-Path C:\users\$env:username\users.csv
""
#########################
"-------------------"
Write-Host -ForegroundColor Green "SECTION 2: Beginning Script..."
"-------------------"
if ($list) {
    "-------------------"
    # Clear Internet Explorer
    Write-Host -ForegroundColor Green "SECTION 5: Clearing Internet Explorer Caches"
     "-------------------"
    Write-Host -ForegroundColor yellow "Clearing Google caches"
    Write-Host -ForegroundColor cyan
    Import-CSV -Path C:\users\$env:username\users.csv | foreach {
        Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\microsoft\Windows\INetCache\*.*" -Recurse -Force -EA SilentlyContinue -Verbose
        Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\microsoft\Windows\WER\*" -Recurse -Force -EA SilentlyContinue -Verbose
        Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Temp\*" -Recurse -Force -EA SilentlyContinue -Verbose
        Remove-Item -path "C:\Windows\Temp\*" -Recurse -Force -EA SilentlyContinue -Verbose
        Remove-Item -path "C:\`$recycle.bin\" -Recurse -Force -EA SilentlyContinue -Verbose
            }

    Write-Host -ForegroundColor yellow "Done..."
    ""
    Write-Host -ForegroundColor Green "All Tasks Done!"
    } else {
    Write-Host -ForegroundColor Yellow "Session Cancelled"  
    Exit
    }
alno_wang 回答:Powershell无法清除IE浏览Cookie,缓存等

好吧,如果发生任何错误,您可以使用-EA SilentlyContinue标志来抑制它们。我会从您的Remove-Item通话中删除该行,看看那里是否存在任何偷偷摸摸的错误。

我不确定您是否打算这样做,但是在您的第一个Remove-Item下的INetCache通话中:

Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Microsoft\Windows\INetCache\*.*"

您将只删除文件名中带有.的文件,基本上只删除带有扩展名的文件。如果要从该目录中删除所有内容,而不管其是否具有文件扩展名,则只需使用*而不是*.*即可,就像其他路径一样。

本文链接:https://www.f2er.com/3116258.html

大家都在问