LiquidObject

« Exchange 2016 Holiday Calendar Loading

Roaming Profile Cookie cleaning

While I’ve made a push to remove Roaming Profiles anywhere I still see them, some organizations are still not ready to move on to newer technologies. One of the problems is stale data as profiles are not regularly refreshed, below is a sample script for cleaning up old cookie data folders.

$Old_Date = (Get-Date).AddDays(-90)

$myprofiles = Get-ChildItem D:\Profiles
foreach($i in $myprofiles)
{
	$myuser = $i.FullName
	$CookiePath = $myuser + "\AppData\Roaming\Microsoft\Windows\Cookies\Low"
	$LowCookiePath = $myuser + "\AppData\Roaming\Microsoft\Windows\Cookies"

	if(Test-Path $CookiePath){
       	     Get-ChildItem $CookiePath | where {($_.LastAccessTime -lt $Old_Date) -and ($_.CreationTime -lt $Old_Date) -and ($_.Extension -eq ".TXT")} | Remove-Item
	     if(Test-Path $LowCookiePath)
		{
          	    Get-ChildItem $LowCookiePath | where {($_.LastAccessTime -lt $Old_Date) -and ($_.CreationTime -lt $Old_Date) -and ($_.Extension -eq ".TXT")} | Remove-Item
		}
	}
}
,
November 3, 2017 at 9:26 pm
Leave a Reply or trackback