Schulkonten abmelden von Microsoft 365 ohne Zugriff
Sollten Schulkonten abgemeldet werden müssen ohne Zugriff auf den Tenant.
Dieses Skript als Administrator via Powershell ausrollen. Dann neustarten, alle Konten sind abgemeldet. Anschließend Office und OneDrive neu installieren.
# Token-Broker beenden
Get-Process Microsoft.AAD.BrokerPlugin -ErrorAction SilentlyContinue | Stop-Process -Force
# WAM/MSAL/ADAL-Caches löschen
$paths = @(
"$env:LOCALAPPDATA\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy\AC\TokenBroker",
"$env:LOCALAPPDATA\Microsoft\IdentityCache",
"$env:LOCALAPPDATA\Microsoft\TokenBroker",
"$env:LOCALAPPDATA\Microsoft\Office\16.0\Identity"
)
foreach ($p in $paths) { if (Test-Path $p) { Remove-Item $p -Recurse -Force -ErrorAction SilentlyContinue } }
# Teams/Office/Outlook bei Bedarf beenden
Get-Process Teams -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process Outlook -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process WINWORD -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process EXCEL -ErrorAction SilentlyContinue | Stop-Process -Force
Write-Host "Caches bereinigt. Bitte Windows neu starten und dann neu anmelden.
Im Anschluss muss dann das Konto noch getrennt werden, da es sonst zu Problemen im DNS kommt.
<#
Rebuild-Workplace-WAM.ps1
- Broker/TokenBroker stoppen
- Caches löschen
- (Optional) Workplace-Registrierung lösen (dsregcmd /leave)
- Broker neu registrieren
- WAM-Konten bereinigen & PRT auffrischen
- WinHTTP-Proxy auf DirectAccess
- Einstellungen-Seite "Arbeits- oder Schulkonto" öffnen
#>
$ErrorActionPreference = 'Continue'
function Step($t){ Write-Host "`n==> $t" -ForegroundColor Cyan }
Step "Status vorab (dsregcmd /status)…"
cmd /c "dsregcmd /status"
Step "Prozesse stoppen (AAD Broker / Runtime / Background)…"
Get-Process Microsoft.AAD.BrokerPlugin -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process RuntimeBroker -ErrorAction SilentlyContinue | Stop-Process -Force
Get-Process BackgroundTaskHost -ErrorAction SilentlyContinue | Stop-Process -Force
Step "Token-/Identity-Caches löschen…"
$paths = @(
"$env:LOCALAPPDATA\Packages\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy\AC\TokenBroker",
"$env:LOCALAPPDATA\Microsoft\IdentityCache",
"$env:LOCALAPPDATA\Microsoft\TokenBroker",
"$env:LOCALAPPDATA\Microsoft\Office\16.0\Identity"
)
foreach ($p in $paths) { if (Test-Path $p) { Remove-Item $p -Recurse -Force -ErrorAction SilentlyContinue; Write-Host " gelöscht: $p" } }
# --- OPTIONAL: Workplace-Registrierung sauber lösen ---
$ans = Read-Host "Workplace-Registrierung (Access work or school) vollständig LÖSEN? (empfohlen) (j/n)"
if ($ans -match '^[jJ]') {
Step "Workplace-Registrierung lösen (dsregcmd /leave)…"
cmd /c "dsregcmd /leave"
} else {
Write-Host "Übersprungen." -ForegroundColor Yellow
}
# Broker neu registrieren
Step "AAD Broker Plugin neu registrieren…"
$manifest = "C:\Windows\SystemApps\Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy\AppxManifest.xml"
if (Test-Path $manifest) {
Add-AppxPackage -Register $manifest -DisableDevelopmentMode -ForceApplicationShutdown
Write-Host " OK."
} else {
Write-Host " WARN: Manifest nicht gefunden: $manifest" -ForegroundColor Yellow
}
# WAM cleanup & PRT refresh
Step "WAM-Konten bereinigen & PRT auffrischen…"
cmd /c "dsregcmd /cleanupaccounts"
cmd /c "dsregcmd /refreshprt"
# Proxy sicherstellen
Step "WinHTTP-Proxy auf DirectAccess…"
cmd /c "netsh winhttp reset proxy" | Out-Null
cmd /c "netsh winhttp show proxy"
Step "Status danach (dsregcmd /status)…"
cmd /c "dsregcmd /status"
Write-Host "`n✅ Jetzt die Arbeits-/Schulkonten neu verbinden." -ForegroundColor Green
Start-Process "ms-settings:workplace"
Write-Host "`n👉 Schrittfolge in der UI:"
Write-Host " 1) ALTE Konten in 'Arbeits- oder Schulkonto' trennen (falls noch sichtbar)."
Write-Host " 2) 'Verbinden' klicken und **das richtige Konto** hinzufügen (z. B. difa-aalen.de)."
Write-Host " 3) Nach der Verbindung: Office/OneDrive/Store starten und anmelden."
Write-Host " 4) Danach 'dsregcmd /listaccounts' → sollte mind. 1 'Account:' zeigen."