-
Notifications
You must be signed in to change notification settings - Fork 5
/
CleanPerUserReceiverInstall.ps1
352 lines (317 loc) · 16.9 KB
/
CleanPerUserReceiverInstall.ps1
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
$RegistryKeys = "
Software\Classes\CCMLib.CCM.*
Software\Classes\Citrix.ICAClient.*
Software\Classes\Citrix.ICAClientProp.*
Software\Classes\IcaMimeFilter.IcaMimeFilterPP.*
Software\Classes\IEInterceptor.InterceptorBHO.*
Software\Classes\.cr
Software\Classes\.vfm
Software\Classes\AppID\{C481B12A-93FC-4D68-9BCD-B68144CC4265}
Software\Classes\AppID\{C910F0DE-7697-490F-9FFC-9235446FCC74}
Software\Classes\AppID\{CA6A1809-03CD-4711-8018-BB56B7A8499B}
Software\Classes\AppID\{DCC5A9B9-2C0F-4C4C-8E68-CD65248CBBDE}
Software\Classes\AppID\{E3F9C65D-5E4C-4A7E-B2CD-CA274FE7DB3D}
Software\Classes\AppID\{E63F16AA-7C16-4697-826C-98B7A5092299}
Software\Classes\AppID\AuthManSvr.EXE
Software\Classes\AppID\IEInterceptor.DLL
Software\Classes\AppID\PrimaryAuthInterfaces.DLL
Software\Classes\AppID\PrimaryAuthModule.EXE
Software\Classes\Applications\CDViewer.exe
Software\Classes\Applications\cpviewer.exe
Software\Classes\Applications\CtxTwnPA.exe
Software\Classes\Applications\migraten.exe
Software\Classes\Applications\wfcrun32.exe
Software\Classes\Applications\wfica32.exe
Software\Classes\Applications\wfrcun32.exe
Software\Classes\Applications\XPSPrintHelper.exe
Software\Classes\CCMLib.CCM.1
Software\Classes\Citrix.ICAClient
Software\Classes\Citrix.ICAClient.2
Software\Classes\Citrix.ICAClient.2.1
Software\Classes\Citrix.ICAClient.2.2
Software\Classes\Citrix.ICAClient.2.3
Software\Classes\Citrix.ICAClient.2.4
Software\Classes\Citrix.ICAClient.2.5
Software\Classes\Citrix.ICAClient.2.6
Software\Classes\Citrix.ICAClient.2.7
Software\Classes\Citrix.ICAClient.2.8
Software\Classes\Citrix.ICAClient.2.9
Software\Classes\Citrix.ICAClientProp.2
Software\Classes\Citrix.ICAClientProp.2.1
Software\Classes\Citrix.ICAClientProp.2.2
Software\Classes\Citrix.ICAClientProp.2.3
Software\Classes\CLSID\{0BB94541-4EB9-4134-B201-E1E33B78DEE6}
Software\Classes\CLSID\{1AAB6B53-7918-406B-B1F5-27B4CCC4B6D8}
Software\Classes\CLSID\{1EFF7739-9BDA-4295-BC07-383554CAAC84}
Software\Classes\CLSID\{22FFB406-4DE5-4877-9FB8-5C6621D7A778}
Software\Classes\CLSID\{238F6F83-B8B4-11CF-8771-00A024541EE3}
Software\Classes\CLSID\{2A93ACBB-F018-4A4A-8C3D-7F5179535CFA}
Software\Classes\CLSID\{2C4631FF-5CC8-4EBC-A0DF-34C92291759E}
Software\Classes\CLSID\{37344F01-EF11-45B8-90EB-5FFF94A07EC0}
Software\Classes\CLSID\{40C3614B-BC5E-4D87-A1BA-DDD18AC9CDD2}
Software\Classes\CLSID\{48D3AF09-BB6F-455B-B1CB-E5459B194AA4}
Software\Classes\CLSID\{5EAAB646-8CD5-4CB4-B764-D0EC2724CC41}
Software\Classes\CLSID\{77D6E619-DF21-45BC-9699-F47363A812D1}
Software\Classes\CLSID\{7947444A-7485-4120-A1A6-BC8B0AA7699A}
Software\Classes\CLSID\{829C4FE4-A7F1-4973-BAE1-4F0C5D54CC12}
Software\Classes\CLSID\{9BC2D672-5719-11D2-A0E8-00A0C9DA3B35}
Software\Classes\CLSID\{9BC2D673-5719-11D2-A0E8-00A0C9DA3B35}
Software\Classes\CLSID\{9BC2D675-5719-11D2-A0E8-00A0C9DA3B35}
Software\Classes\CLSID\{9BC2D676-5719-11D2-A0E8-00A0C9DA3B35}
Software\Classes\CLSID\{9EF5EF7A-DB82-464A-ACD0-1BC9416E3268}
Software\Classes\CLSID\{98DB51B7-BDC6-484B-9844-18DA73D506B6}
Software\Classes\CLSID\{BDE6DF17-29A7-4471-AC7D-638B9E7D6F37}
Software\Classes\CLSID\{CFB6322E-CC85-4d1b-82C7-893888A236BC}
Software\Classes\CLSID\{D085A4AB-CAB1-4729-9DF8-FCEEDDBD19E4}
Software\Classes\CLSID\{DF3E2F2D-6863-4DCB-A174-3C0B2090C420}
Software\Classes\CLSID\{E5A04DAB-5D65-448F-B919-79F108F05182}
Software\Classes\CLSID\{E61FEC89-CFBB-43A1-AC1D-4656D3714F4F}
Software\Classes\CLSID\{E63F16AA-7C16-4697-826C-98B7A5092299}
Software\Classes\CLSID\{FE038EF1-568F-41AD-A80A-70CCF5B68259}
Software\Classes\cr.Document
Software\Classes\IcaMimeFilter.IcaMimeFilterPP
Software\Classes\IcaMimeFilter.IcaMimeFilterPP.1
Software\Classes\IEInterceptor.InterceptorBHO
Software\Classes\IEInterceptor.InterceptorBHO.1
Software\Classes\Interface\{010A6A8D-FABF-4183-B6B5-381543AE77D5}
Software\Classes\Interface\{0CC96E69-3EB8-41CD-9962-9319408C4742}
Software\Classes\Interface\{2356A355-6B99-4BA0-9CBF-6C13789A9887}
Software\Classes\Interface\{239D08F9-0EC1-43F1-96D9-D11C3FB10A8E}
Software\Classes\Interface\{3C7A7B05-5DAD-4099-A648-BEC79913B591}
Software\Classes\Interface\{5F3E0046-60A7-4b20-BA28-114A815D7D06}
Software\Classes\Interface\{5F6A8DB8-51DF-413D-946C-F424A3168C35}
Software\Classes\Interface\{68A8653F-5787-48E3-A0D9-B2C33FAC824A}
Software\Classes\Interface\{70B90098-4EC5-49f2-8F3B-45A980ABBE92}
Software\Classes\Interface\{91602FD4-080E-44E5-BC6C-7AEBB7C36F2D}
Software\Classes\Interface\{9C25DF55-32BE-46E6-A0BE-844F4C937651}
Software\Classes\Interface\{9D94AB72-8555-4057-96A4-C9C76804A5E7}
Software\Classes\Interface\{ABCAD60C-D071-4683-AC98-50AEB736B2A2}
Software\Classes\Interface\{C45B7921-9578-4E38-92B1-18346DA5B84B}
Software\Classes\Interface\{CBACA88C-FA22-4B27-9F2A-7A0517227FE3}
Software\Classes\Interface\{CD189584-4589-47f4-9CE8-DAAE3DF8E098}
Software\Classes\Interface\{DAE32A9F-DC07-4EE1-8EB1-944E060694F4}
Software\Classes\Interface\{E197F39F-A877-4df3-BD95-73273CBC2F9E}
Software\Classes\Interface\{E50A3292-626E-42f7-AD26-F6F80F1E656F}
Software\Classes\Interface\{E61FEC89-CFBB-43A1-AC1D-4656D3714F4F}
Software\Classes\Interface\{EA2C18E8-D689-4fa8-AEA9-19453289AB0C}
Software\Classes\Interface\{EF1D262D-C892-44EE-B992-C3F26DCDD326}
Software\Classes\Interface\{F5521495-CBB5-4ab6-8FD7-A7228876D6DE}
Software\Classes\Interface\{FB72D14F-F8CB-46d4-B521-D7CBDC2C54AC}
Software\Classes\Interface\{FE5709E6-2EBA-4d56-A1BE-F3D7AAD09ABD}
Software\Classes\Interface\{FEF88E72-BA7D-4F09-8A14-816D8EB39987}
Software\Classes\Interface\{FFD342B6-22D8-4996-BAEC-1CD5FB74D7B1}
Software\Classes\MIME\Database\Content Type\application/vnd.citrix.receiver.configure
Software\Classes\MIME\Database\Content Type\application/x-ica
Software\Classes\MIME\Database\Content Type\application/x-ica; charset=euc-jp
Software\Classes\MIME\Database\Content Type\application/x-ica; charset=ISO-8859-1
Software\Classes\MIME\Database\Content Type\application/x-ica; charset=MS936
Software\Classes\MIME\Database\Content Type\application/x-ica; charset=MS949
Software\Classes\MIME\Database\Content Type\application/x-ica; charset=MS950
Software\Classes\MIME\Database\Content Type\application/x-ica; charset=UTF8
Software\Classes\MIME\Database\Content Type\application/x-ica; charset=UTF-8
Software\Classes\MIME\Database\Content Type\application/x-ica;charset=euc-jp
Software\Classes\MIME\Database\Content Type\application/x-ica;charset=ISO-8859-1
Software\Classes\MIME\Database\Content Type\application/x-ica;charset=MS936
Software\Classes\MIME\Database\Content Type\application/x-ica;charset=MS949
Software\Classes\MIME\Database\Content Type\application/x-ica;charset=MS950
Software\Classes\MIME\Database\Content Type\application/x-ica;charset=UTF8
Software\Classes\MIME\Database\Content Type\application/x-ica;charset=UTF-8
Software\Classes\PROTOCOLS\Filter\application/x-ica
Software\Classes\PROTOCOLS\Filter\application/x-ica; charset=euc-jp
Software\Classes\PROTOCOLS\Filter\application/x-ica; charset=ISO-8859-1
Software\Classes\PROTOCOLS\Filter\application/x-ica; charset=MS936
Software\Classes\PROTOCOLS\Filter\application/x-ica; charset=MS949
Software\Classes\PROTOCOLS\Filter\application/x-ica; charset=MS950
Software\Classes\PROTOCOLS\Filter\application/x-ica; charset=UTF8
Software\Classes\PROTOCOLS\Filter\application/x-ica; charset=UTF-8
Software\Classes\PROTOCOLS\Filter\application/x-ica;charset=euc-jp
Software\Classes\PROTOCOLS\Filter\application/x-ica;charset=ISO-8859-1
Software\Classes\PROTOCOLS\Filter\application/x-ica;charset=MS936
Software\Classes\PROTOCOLS\Filter\application/x-ica;charset=MS949
Software\Classes\PROTOCOLS\Filter\application/x-ica;charset=MS950
Software\Classes\PROTOCOLS\Filter\application/x-ica;charset=UTF8
Software\Classes\PROTOCOLS\Filter\application/x-ica;charset=UTF-8
Software\Classes\PROTOCOLS\Filter\ica
Software\Classes\receiver
Software\Classes\Record\{282756C7-7342-43BE-A109-05B9B3771143}
Software\Classes\Record\{362E1B72-7D89-4BA7-9002-899026F4EB7C}
Software\Classes\Record\{58321056-F662-4F07-8B79-A1D3F899A576}
Software\Classes\Record\{652A4EDE-6BF5-470F-9311-EC2F4ED6552D}
Software\Classes\Record\{782B14CE-D70B-4AA3-BB69-BE823B83ED36}
Software\Classes\Record\{82B81996-3BD1-4745-B91F-B94BD586251C}
Software\Classes\Record\{96717021-9FC9-45A0-8F49-1370520C4B07}
Software\Classes\Record\{CD60F3E6-2B98-4E0A-8009-D54CC7F987E4}
Software\Classes\Record\{CE6FC689-A980-49F3-86CD-D7D8D999B88E}
Software\Classes\Record\{CFA1BA68-D227-4D9D-9595-5E5EF533D8F0}
Software\Classes\Record\{D242C42B-3154-4F7D-BD5E-2AF3E9C117DF}
Software\Classes\Record\{D9057076-F1E4-4330-B06B-ECF73831489F}
Software\Classes\Record\{DAE7D2C5-2E95-4806-B1EB-1CF4B8BAE483}
Software\Classes\TypeLib\{238F6F80-B8B4-11CF-8771-00A024541EE3}
Software\Classes\TypeLib\{2D646468-6FEC-408C-B7CF-FB258D2AA0EB}
Software\Classes\TypeLib\{3D3FCA3F-FA3F-4ACB-A793-DF6FFACC991A}
Software\Classes\TypeLib\{6242C275-4165-41C3-B283-A41EEEDB06D1}
Software\Classes\TypeLib\{919B1DD4-91CE-455A-9CB3-437BFE502117}
Software\Classes\TypeLib\{A2E3CD1C-C98A-4F62-9F6B-CA40E8E5CA34}
Software\Classes\TypeLib\{C43C22AF-CC33-43c0-9E0E-E843087AE46C}
Software\Classes\TypeLib\{D64F442E-E913-4F5E-82B3-38EF598ACB03}
Software\Classes\TypeLib\{EFB05D6B-8E25-42E0-8F11-D2BDA535CD85}
Software\Classes\WinFrameICA
SOFTWARE\Citrix\AuthManager
SOFTWARE\Citrix\CitrixCAB
Software\Citrix\Dazzle
SOFTWARE\Citrix\ICA Client
SOFTWARE\Citrix\Install\{70755658-255B-4EA6-BF8F-7188BDCFF7D0}
SOFTWARE\Citrix\Install\{94F321B9-45B0-4125-970D-DE3D98CBCA1C}
Software\Citrix\Install\DesktopViewer
SOFTWARE\Citrix\Install\ICA Client
Software\Citrix\Install\ReceiverInsideForOnline
SOFTWARE\Citrix\Install\SSON
Software\Citrix\InstallDetect\{6245E940-DA64-4D98-ACBB-56CEEE42E684}
Software\Citrix\InstallDetect\{A9852000-047D-11DD-95FF-0800200C9A66}
SOFTWARE\Citrix\Program Neighborhood Agent
Software\Citrix\Receiver
Software\Citrix\XenDesktop
SOFTWARE\Google\Chrome\Extensions\cbbdcpniegbhplnlpaedigdmmleppddg
Software\Microsoft\Internet Explorer\Low Rights\ElevationPolicy\{98d6e2ad-7673-4742-8b34-6d327771a66d}
SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Browser Helper Objects\{2C4631FF-5CC8-4EBC-A0DF-34C92291759E}
SOFTWARE\MozillaPlugins\@Citrix.com/npican
SOFTWARE\MozillaPlugins\@Citrix.com/npURLInterceptor
SOFTWARE\Policies\Citrix\ICA Client"
$CLSIDValues = "
\Citrix\ICA Client\
\Citrix\AuthManager\
\Citrix\SelfService\
AuthManager Class
AuthSingleUseFactory Class
PSFactoryBuffer
CCM
IcaMimeFilterPP Class
MediaFoundationTopology Class
DirectShowTopology Class
Citrix URL-Redirection Helper
PSFactoryBuffer
HDX264Impl Class
Citrix ICA Client Properties"
$InterfaceValues = "
IAuthenticatorSupport
ISingleUseFactory
IAuthenticationContext
IAuthHttpRequest
IAuthManager
IRestrictedObject
IOwnedProcess
IPrimaryAuthenticator
IDebugging
_IPrimaryAuthenticatorEvents
IVpnAuthenticationContext
ICookieJar
_IAuthManagerEvents
IEvents_ConnectionCtrl
ICtxRedirector
IConnectionCtrl_PrivateICO
IEvents_SessionState
IEvents_SessionSharing
IEvents_PrivateICO
ICCMCtrl2
IEvents_VirtualChannel
IEvents_SessionError
ICCMCtrl
IConnectionCtrl
IEvents_Application
IInterceptorBHO
IConnectionCtrl2"
$InstallerProductNames = "
Citrix Web Helper
Citrix Receiver*
Self-service Plug-in
Online Plug-in
Citrix Authentication Manager"
$RegistryKeys = $RegistryKeys.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries)
$CLSIDValues = $CLSIDValues.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries)
$InterfaceValues = $InterfaceValues.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries)
$InstallerProductNames = $InstallerProductNames.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries)
$ScriptPath = Split-Path -Path $MyInvocation.MyCommand.Path
$ProcessPaths = @('*\Citrix\ICA Client\*', '*\Citrix\Receiver\*', '*\Citrix\AuthManager\*', '*\Citrix\SelfService\*', '*\Citrix\Citrix Receiver\*')
$CtxRCUPath = ($ScriptPath + '\ReceiverCleanupUtility.exe')
$PatternSID = 'S-1-5-21-\d+-\d+\-\d+\-\d+$'
ForEach ($ProcessPath in $ProcessPaths) {
$TempProcesses = @(Get-Process | Where {$_.Path -like $ProcessPath})
If ($TempProcesses) {
ForEach ($TempProcess in $TempProcesses) {
Write-Host ("Stopping process: " + $TempProcess.Name)
$TempProcess | Stop-Process -Force
}
}
}
$UserProfilesDirectory = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\').ProfilesDirectory
$ProfileList = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\*' | Where-Object {$_.PSChildName -match $PatternSID} | Select @{name="SID";expression={$_.PSChildName}}, @{name="UserClassesHive";expression={"$($_.ProfileImagePath)\AppData\Local\Microsoft\Windows\Usrclass.dat"}} , @{name="UserHive";expression={"$($_.ProfileImagePath)\ntuser.dat"}}, @{name="Username";expression={$_.ProfileImagePath -replace '^(.*[\\\/])', ''}}
$LoadedHives = Get-ChildItem Registry::HKEY_USERS | Where-Object {$_.PSChildname -match $PatternSID} | Select @{name="SID";expression={$_.PSChildName}}
$UnloadedHives = Compare-Object -ReferenceObject ($ProfileList | Select -ExpandProperty SID) -DifferenceObject ($LoadedHives | Select -ExpandProperty SID) | Select @{name="SID";expression={$_.InputObject}}
ForEach ($Profile in $ProfileList) {
If ($UnloadedHives.SID -contains $Profile.SID) {
Write-Host "Loading profile registry hives for username: $($Profile.Username)"
reg load HKU\$($Profile.SID) $($Profile.UserHive) | Out-Null
reg load HKU\$($Profile.SID)_Classes $($Profile.userClassesHive) | Out-Null
}
}
Write-Host ""
Write-Host "Running Citrix Reciever Cleanup Utility..."
Start-Process -FilePath $CtxRCUPath -ArgumentList '/silent /disableCEIP' -Wait
Write-Host ""
ForEach ($Profile in $ProfileList) {
Write-Host "Running post-RCU registry cleanup for username: $($Profile.Username)"
ForEach ($RegistryKey in $RegistryKeys) {
Remove-Item -Path "registry::HKEY_USERS\$($Profile.SID)\$RegistryKey" -Recurse -Force -ErrorAction SilentlyContinue
#Write-Host "registry::HKEY_USERS\$($Profile.SID)\$RegistryKey"
If (($RegistryKey -like 'Software\Classes\Interface\*') -or ($RegistryKey -like 'Software\Classes\CLSID\*')) {
$RegistryKeyWow6432 = $RegistryKey.Replace('Software\Classes\', 'Software\Classes\WOW6432Node\')
Remove-Item -Path "registry::HKEY_USERS\$($Profile.SID)\$RegistryKeyWow6432" -Recurse -Force -ErrorAction SilentlyContinue
#Write-Host "registry::HKEY_USERS\$($Profile.SID)\$RegistryKeyWow6432"
}
}
#CLSID Key Search
$CLSIDKeys = @(Get-Item -Path "registry::HKEY_USERS\$($Profile.SID)\Software\Classes\CLSID" -ErrorAction SilentlyContinue | Get-ChildItem)
$CLSIDKeys = $CLSIDKeys + @(Get-Item -Path "registry::HKEY_USERS\$($Profile.SID)\Software\Classes\WOW6432Node\CLSID" -ErrorAction SilentlyContinue | Get-ChildItem)
ForEach ($CLSIDKey in $CLSIDKeys) {
$CLSIDPropMatches = @()
$CLSIDProps = @($CLSIDKey | Get-ItemProperty)
$CLSIDProps = $CLSIDProps + @($CLSIDKey | Get-ChildItem -Recurse | Get-ItemProperty)
ForEach ($CLSIDValue in $CLSIDValues) {
$CLSIDPropMatches = $CLSIDPropMatches + ($CLSIDProps | Where {$_ -like "*$CLSIDValue*"})
}
If ($CLSIDPropMatches.Count -gt 0) {
#Write-Host $CLSIDKey.PSPath
$CLSIDKey | Remove-Item -Recurse -Force
}
}
#Interface Key Search
$InterfaceKeys = @(Get-Item -Path "registry::HKEY_USERS\$($Profile.SID)\Software\Classes\Interface" -ErrorAction SilentlyContinue | Get-ChildItem)
$InterfaceKeys = $InterfaceKeys + @(Get-Item -Path "registry::HKEY_USERS\$($Profile.SID)\Software\Classes\WOW6432Node\Interface" -ErrorAction SilentlyContinue | Get-ChildItem)
ForEach ($InterfaceKey in $InterfaceKeys) {
$InterfacePropMatches = @()
$InterfaceProps = @($InterfaceKey | Get-ItemProperty)
$InterfaceProps = $InterfaceProps + @($InterfaceKey | Get-ChildItem -Recurse | Get-ItemProperty)
ForEach ($InterfaceValue in $InterfaceValues) {
$InterfacePropMatches = $InterfacePropMatches + ($InterfaceProps | Where {$_ -like "*$InterfaceValue*"})
}
If ($InterfacePropMatches.Count -gt 0) {
#Write-Host $InterfaceKey.PSPath
$InterfaceKey | Remove-Item -Recurse -Force
}
}
#Installer Product Search
$InstallerProductKeys = @()
ForEach ($InstallerProductName in $InstallerProductNames) {
$InstallerProductKeys = $InstallerProductKeys + @(Get-Item -Path "registry::HKEY_USERS\$($Profile.SID)\Software\Microsoft\Installer\Products" -ErrorAction SilentlyContinue | Get-ChildItem | Get-ItemProperty | Where {$_.ProductName -like $InstallerProductName})
}
ForEach ($InstallerProductKey in $InstallerProductKeys) {
#Write-Host $InstallerProductKey.PSPath
$InstallerProductKey | Remove-Item -Recurse -Force
}
If ($UnloadedHives.SID -contains $Profile.SID) {
Write-Host "Unloading profile registry hives for username: $($Profile.Username)"
[gc]::Collect()
reg unload HKU\$($Profile.SID) | Out-Null
reg unload HKU\$($Profile.SID)_Classes | Out-Null
}
}