Office Licentie Cleanup Script. Verwijdert automatisch alle geïnstalleerde Office productkeys:
$OsppPath = "C:\Program Files\Microsoft Office\root\Office16\ospp.vbs"
if (-not (Test-Path $OsppPath)) {
Write-Host "Office niet gevonden op standaard locatie" -ForegroundColor Red
}
$status = cscript //nologo $OsppPath /dstatus
$keys = $status | Select-String -Pattern "Last 5 characters of installed product key: (\w{5})" |
ForEach-Object { $_.Matches.Groups[1].Value }
if ($keys.Count -eq 0) {
Write-Host "Geen productkeys gevonden om te verwijderen" -ForegroundColor Yellow
}
Write-Host "Gevonden keys: $($keys.Count)" -ForegroundColor Cyan
foreach ($key in $keys) {
Write-Host "Verwijderen key eindigend op: $key" -ForegroundColor Yellow
$result = cscript //nologo $OsppPath /unpkey:$key
if ($result -match "success") {
Write-Host " Verwijderd" -ForegroundColor Green
} else {
Write-Host " Fout: $result" -ForegroundColor Red
}
}
Bekijk huidige licenties:
cd "C:\Program Files\Microsoft Office\root\Office16"
cscript ospp.vbs /dstatus
Verwijder oude productkeys (vervang XXXXX door laatste 5 chars van de key):
cscript ospp.vbs /unpkey:XXXXX
https://www.microsoft.com/en-us/download/details.aspx?id=49117
Installeer met expliciete product ID en verwijder andere producten
Start-Process -FilePath "C:\SetupOffice.exe" -ArgumentList "/CONFIGURE C:\SetupOffice.xml" -Wait