-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathClear-ChromePolicySettings.ps1
140 lines (90 loc) · 4.72 KB
/
Clear-ChromePolicySettings.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
<#
.SYNOPSIS
This cmdlet was created to quickly remove Chrome policy settings that have been configured by group policy in the Windows Registry.
.DESCRIPTION
You can modify Chrome group policy settings however Chrome does not delete old ones or provide any way to implement changes for example with browser extensions when an organization changes products. Firefox handles Chrome group policy settings better than Chrome does which cracks me up because Cgrome made the settings.
.PARAMETER ComputerName
Defines the FQDN or hostname of a remote device you wish to clear the registry settings on using WinRM
.PARAMETER UseSSL
Switch parameter that indicates you want to use WinRM over HTTPS
.EXAMPLE
Clear-ChromePolicySettings
# This example clears the group policy settings that affect the Chrome browser
.EXAMPLE
Clear-ChromePolicySettings -ComputerName DESKTOP01.domain.com,DESKTOP02.domain.com
# This example clears the group policy settings that affect the Chrome browser on remote devices DESKTOP01 and DESKTOP02
.EXAMPLE
Clear-ChromePolicySettings -ComputerName DESKTOP01.domain.com,DESKTOP02.domain.com -UseSSL
# This example clears the group policy settings that affect the Chrome browser on remote devices DESKTOP01 and DESKTOP02 using WinRM over HTTPS
.NOTES
Author: Robert H. Osborne
Alias: tobor
Contact: [email protected]
.LINK
https://osbornepro.com
https://writeups.osbornepro.com
https://btps-secpack.com
https://github.com/tobor88
https://gitlab.com/tobor88
https://www.powershellgallery.com/profiles/tobor
https://www.linkedin.com/in/roberthosborne/
https://www.youracclaim.com/users/roberthosborne/badges
https://www.hackthebox.eu/profile/52286
.INPUTS
None
.OUTPUTS
None
#>
Function Clear-ChromePolicySettings {
[CmdletBinding(DefaultParameterSetName='Local')]
param(
[Parameter(
ParameterSetName='Remote',
Mandatory=$False,
ValueFromPipeline=$False,
HelpMessage="`n[H] Define the FQDN or remote Windows devices you wish to clear the Chrome policy settings on. `n[E] EXAMPLE: DESKTOP01.domain.com,DESKTOP02.domain.com")] # End Parameter
[String[]]$ComputerName,
[Parameter(
ParameterSetName='Remote',
Mandatory=$False,
ValueFromPipeline=$False)] # End Parameter
[Switch][Bool]$UseSSL
) # End param
$DeleteRegItems = 'HKCU:\Software\Google\Chrome','HKCU:\Software\Policies\Google\Chrome','HKLM:\Software\Google\Chrome','HKLM:\Software\Policies\Google\Chrome','HKLM:\Software\Policies\Google\Update','HKLM:\Software\WOW6432Node\Google\Enrollment','HKLM:\Software\WOW6432Node\Google\Update\ClientState\{430FD4D0-B729-4F61-AA34-91526481799D}','C:\Program Files (x86)\Google\Policies'
Switch ($PSCmdlet.ParameterSetName) {
'Local' {
Write-Verbose "Stopping open Chrome processes"
Get-Process -Name chrome -ErrorAction SilentlyContinue | Stop-Process | Out-Null
Write-Verbose "Removing Chrome Policy Settings from $env:COMPUTERNAME"
Remove-Item -Path $DeleteRegItems -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
ForEach ($Path in $DeleteRegItems) {
If ((Test-Path -Path $Path) -and ($Path -ne 'HKLM:\Software\Google\Chrome')) {
Write-Output "[!] FAILURE: $Path was unable to be deleted"
} # End If
Else {
Write-Output "[*] SUCCESS: Deleted settings at $Path"
} # End Else
} # End ForEach
} # End Switch Local
'Remote' {
$Bool = $False
If ($UseSSL.IsPresent) {
$Bool = $True
} # End If
Invoke-Command -HideComputerName $ComputerName -UseSSL:$Bool -ArgumentList $DeleteRegItems -ScriptBlock {
Write-Verbose "Stopping open Chrome processes"
Get-Process -Name chrome -ErrorAction SilentlyContinue | Stop-Process | Out-Null
Write-Verbose "Removing Chrome Policy Settings from $env:COMPUTERNAME"
Remove-Item -Path $Args -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
ForEach ($Path in $Args) {
If ((Test-Path -Path $Path) -and ($Path -ne 'HKLM:\Software\Google\Chrome')) {
Write-Output "[!] FAILURE: $Path was unable to be deleted"
} # End If
Else {
Write-Output "[*] SUCCESS: Deleted settings at $Path"
} # End Else
} # End ForEach
} # End ScriptBlock
} # End Switch Remote
} # End Switch
} # End Function Clear-ChromePolicySettings