Write-Output "=== Clearing stale token broker cache ==="
$aadBroker = Get-ChildItem "C:\Users\*\AppData\Local\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy" -Directory -ErrorAction SilentlyContinue
foreach ($p in $aadBroker) {
    $ac = Join-Path $p.FullName "AC\TokenBroker"
    if (Test-Path $ac) {
        Remove-Item "$ac\*" -Recurse -Force -ErrorAction SilentlyContinue
        Write-Output "Cleared: $ac"
    }
}
$msAccount = Get-ChildItem "C:\Users\*\AppData\Local\Packages\Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy" -Directory -ErrorAction SilentlyContinue
foreach ($p in $msAccount) {
    $ac = Join-Path $p.FullName "AC\TokenBroker"
    if (Test-Path $ac) {
        Remove-Item "$ac\*" -Recurse -Force -ErrorAction SilentlyContinue
        Write-Output "Cleared: $ac"
    }
}
Write-Output ""
Write-Output "Cache cleared. Reboot the machine, then log in as cascades\pilot.test."
Write-Output "The fresh login should acquire a PRT and Edge will SSO into ALIS automatically."
