Eat the cookie! – ADFS – Powershell

So tired of getting problems with ADFS cookies, so decided to find an easier way than IE to clear my local cookies using a script. This script works on Windows 8.1. I would expect it to work on 8.0 but not on lower versions, as the location of the IE cookies is different.

# Location of IE Cookies
$Path = $env:USERPROFILE + "\AppData\Local\Microsoft\Windows\INetCookies\Low"
$Text = <domain name of cookie>
$PathArray = @()

# Cookies are stored as .txt files.
Get-ChildItem $Path -Filter "*.txt" | Where-Object { $_.Attributes -ne "Directory"} |
      ForEach-Object {
         If (Get-Content $_.FullName | Select-String -Pattern $Text) {
            $PathArray += $_.FullName
         }
      }
$Unique=$PathArray | ForEach-Object {$_} | Get-Unique
$Unique | Remove-Item
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s