forked from borapeksev/RDC-Telemetry-Fix
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFix-RDCProfileBloat.ps1
More file actions
48 lines (39 loc) · 1.76 KB
/
Copy pathFix-RDCProfileBloat.ps1
File metadata and controls
48 lines (39 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<#
.SYNOPSIS
Remediates bloated user profiles caused by MSI Remote Desktop Client telemetry.
.DESCRIPTION
This script iterates through all local user profiles, removes the DiagConnectionCache registry key,
and disables EnableMSRDCTelemetry to prevent future bloating of ntuser.dat.
.NOTES
Test before running in production. Run as Administrator.
#>
$regPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
$sids = Get-ChildItem -Path $regPath
foreach ($sid in $sids) {
$userSid = $sid.PSChildName
# Check if SID matches domain user pattern (S-1-5-21-*)
if ($userSid -match "^S-1-5-21-") {
$profilePath = (Get-ItemProperty -Path $sid.PSPath).ProfileImagePath
if ($profilePath) {
$userName = Split-Path -Leaf $profilePath
Write-Output "Processing domain user: $userName (SID: $userSid)"
# Remove DiagConnectionCache
$rdcRegCache = "Registry::HKEY_USERS\$userSid\Software\Microsoft\RdClientRadc\DiagConnectionCache"
if (Test-Path $rdcRegCache) {
Remove-Item -Path $rdcRegCache -Recurse -Force
Write-Output "Removed: $rdcRegCache"
} else {
Write-Output "Not found: $rdcRegCache"
}
# Disable telemetry
$rdcRegRoot = "Registry::HKEY_USERS\$userSid\Software\Microsoft\RdClientRadc"
if (Test-Path $rdcRegRoot) {
Set-ItemProperty -Path $rdcRegRoot -Name "EnableMSRDCTelemetry" -Value 0
Write-Output "Telemetry disabled: $rdcRegRoot"
} else {
Write-Output "Not found: $rdcRegRoot"
}
}
}
}
Write-Output "Script completed."