Ana içeriğe atla

Powershell ile Web Tarayıcı Cookie Temizliği

Web tarayıcıların ürettiği cookie ve minik boyuttaki veriler uzun bi süre temizlenmediği durumda yüksek boyutlara ulaşabilir ve bilgisayarımızın performansını kötü etkileyebilir.

Bu tarz cookie temizliği ve yönetimi işlemlerinin periyodik olarak yapılması bilgisayarımızın performansı arttıracak ve disk alanı üzerinde bize bir miktarda olsa yer kazandıracaktır.

Bu tarz işlemleri yapan programlar internette mevcut ancak bazılarının güvenilirliği tartışılır ve cookie temizliği işlemini periyodik olarak yapmıyor.

Powershell ile arkaplan işlerini ve browser yönetimi özelliklerini kullanarak cookie yönetimini ve temizliğini periyodik olarak gerçekleştirmek mümkün. Bu sayede hem güvenlik konusunda hem de işlevsellik konusunda kullanıcı dostu bir modül yapmak mümkündür.

Aşağıdaki powershell komutları browser üzerindeki cookie temizliği işlemini yapmaktadır.

Not: Cookie Temizleme işlemini yapan fonksiyon aşağıdaki github projesinden alıntıdır. Bu scriptin üzerine birkaç ekleme ve modifiye ile periyodik çalışması sağlandı :)

Not 2: Powershell ISE programını admin olarak çalıştırmayı unutmayın.

$O = New-ScheduledJobOption -RunElevated
$T = New-JobTrigger -Weekly -At "9:00 PM" -DaysOfWeek Monday -WeeksInterval 2
$Action = {
Write-Host -ForegroundColor yellow "#######################################################"
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 Mozilla Firefox Cache
    Write-Host -ForegroundColor Green "SECTION 3: Clearing Mozilla Firefox Caches"
    "-------------------"
    Write-Host -ForegroundColor yellow "Clearing Mozilla caches"
    Write-Host -ForegroundColor cyan
    Import-CSV -Path C:\users\$env:USERNAME\users.csv -Header Name | foreach {
            Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache\* -Recurse -Force -EA SilentlyContinue -Verbose
            Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache\*.* -Recurse -Force -EA SilentlyContinue -Verbose
    Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cache2\entries\*.* -Recurse -Force -EA SilentlyContinue -Verbose
            Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\thumbnails\* -Recurse -Force -EA SilentlyContinue -Verbose
            Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\cookies.sqlite -Recurse -Force -EA SilentlyContinue -Verbose
            Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\webappsstore.sqlite -Recurse -Force -EA SilentlyContinue -Verbose
            Remove-Item -path C:\Users\$($_.Name)\AppData\Local\Mozilla\Firefox\Profiles\*.default\chromeappsstore.sqlite -Recurse -Force -EA SilentlyContinue -Verbose
            }
    Write-Host -ForegroundColor yellow "Clearing Mozilla caches"
    Write-Host -ForegroundColor yellow "Done..."
    ""
    "-------------------"
    # Clear Google Chrome
    Write-Host -ForegroundColor Green "SECTION 4: Clearing Google Chrome Caches"
    "-------------------"
    Write-Host -ForegroundColor yellow "Clearing Google caches"
    Write-Host -ForegroundColor cyan
    Import-CSV -Path C:\users\$env:USERNAME\users.csv -Header Name | foreach {
            Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cache\*" -Recurse -Force -EA SilentlyContinue -Verbose
Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cache2\entries\*" -Recurse -Force -EA SilentlyContinue -Verbose
            Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cookies" -Recurse -Force -EA SilentlyContinue -Verbose
            Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Media Cache" -Recurse -Force -EA SilentlyContinue -Verbose
            Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\Cookies-Journal" -Recurse -Force -EA SilentlyContinue -Verbose
            # Comment out the following line to remove the Chrome Write Font Cache too.
            # Remove-Item -path "C:\Users\$($_.Name)\AppData\Local\Google\Chrome\User Data\Default\ChromeDWriteFontCache" -Recurse -Force -EA SilentlyContinue -Verbose
            }

    Write-Host -ForegroundColor yellow "Done..."
    ""
    "-------------------"
    # 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\Temporary Internet Files\*" -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
}}

Register-ScheduledJob -Name "Clear Cookie" -ScriptBlock $Action -Trigger $T -ScheduledJobOption $O


knowyourmeme.com/photos/234797-time-to-delete-my-history-again

Yorumlar

Bu blogdaki popüler yayınlar

Powershell ile Windows Restart Kontrolü

Powershell ile Windows üzerinde birçok işlemi daha kolay ve daha kısa sürede yapabilmek mümkündür.  Microsoft, PowerShell'i "görev tabanlı .NET Framework üzerine inşa edilmiş komut satırı shell'i ve komut dizesi olarak tanımlıyor. Powershell'in avantajlarını ise aşağıdaki maddeler ile özetlemek mümkündür. Powershell hem command-line olarak hemde bir scripting language olarak çalışmaktadır. Powershell baş döndürücü sayıda teknolojiyle etkileşim kurabilir.(.NET Framework, the Registry, COM, WMI, ADSI. Exchange, Sharepoint, Systems Center, Hyper-V, SQL.  VMware vCenter , Cisco UCS, Citrix XenApp and XenDesktop. REST APIs, XML, CSV, JSON ...) Powershell nesne tabanlıdır.(Object-Oriented) Bilgisayarımızda ya da sunucumuzda zaman zaman yüklediğimiz programlar ve patchler sonucunda restart işlemi gerekebilir ve bu restart işlemi gerekip gerekmediğini tespit etmek için Powersehell kullanılabilir.  Aynı anda 100 sunucuda bunu öğre...

ASP.NET MVC ile Entity Framework Kullanımı 3(Sum-Average-Top)

Merhaba Arkadaşlar, ASP.NET MVC ile Entity Framework kullanımı yazılarımıza devam ediyoruz. Geçen yazılarımızda Select ve Insert işlemlerini tanıtmıştık kısaca. Bu yazımızda ise,Entity Framework ile daha profesyonel ve advanced select operasyonları üzerinde çalışmalar yapacağız. Veritabanı üzerinde,iş biriminin istekleri basit select sorgusu ile olmayabiliyor. Bizden çekilen verilerin toplanması,ortalanmasının alınması ve ilk "x" kayıdın çekilmesini talep edebiliyorlar. Bu nedenle bu hafta Entity Framework ile Select operasyonlarında gruplama,sıralama ve top konularını inceleyeceğiz. Entity Framework İle Sum Kullanımı Bazen elde edilen verilerden toplam operasyonu gerekmektedir. Bu tarz durumlarda,SUM özelliğini kullanmaktayız. İlk etapta, GetTotalRate isminde integer değer geri veren bir fonksiyon oluşturduk. Daha sonrasında ise ToplamRate isimli değişkenimize EmployeePayHistories tablosunda Rate alanlarının toplam değerini hesaplatıp sonucu atadık. En s...