This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRemove-CiscoWebexLowerThanVersion.ps1
237 lines (223 loc) · 13.6 KB
/
Remove-CiscoWebexLowerThanVersion.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
#Remove Cisco Webex Productivity Tools and Cisco Webex Meetings App Versions LOWER than the definded one!
#Remove-CiscoWebexLowerThanVersion.ps1
#18.11.2021, by sysadmin0815
#Version: 1.2
#Powershell Script tested on Windows 10
#!! ATTENTION !!
#This script removes ALL Cisco Webex Productivity Tools and ALL Cisco Webex Meetings Apps LOWER than the definded Version!
#Think before you use the script, or run it in TEST MODE!!
#TEST MODE; no changes will be done, only logged.
#Enable Test Mode with $true
#Disable Test Mode with $false
$testModeEnabled = $true
#definde Cisco Webex Versions to keep on the system. All versions lower will be removed.
#Change the value to the WebEx version you want to keep.
# Webex Productivity Tools:
$WebexProdToKeepName = "Cisco Webex Productivity Tools" #do not modify unless the Product name changed. Used for logfile
$webexProdToKeepVer = "40" #change to the min. version you want to keep
#Enable or disable the Webex Productivity Tools search and removal
#Enable $true; Disable $false
$webexProd = $true
#Webex Meetings App:
$WebexMeetToKeepName = "Cisco Webex Meetings App" #do not modify unless the Product name changed. Used for logfile
$webexMeetToKeepVer = "40" #change to the min. version you want to keep
#Enable or disable the Webex Meetings App search and removal
#Enable $true; Disable $false
$webExMeet = $true
#Required to build the uninstall string for removal
#do not change this value unless required
$removalProcess = "MsiExec.exe /X"
#Define Log folder
$logFileName = "WebExRemoval-Script.log"
$folderName = "Webex"
$PathLogs = "C:\Windows\Logs\"
$Path = "C:\Windows\Logs\" + $folderName
$PathToLogFile = $Path + "\" + $logFileName
#Test for LogFolder if not create it
if (!(Test-Path $Path)) {
New-Item -itemType Directory -Path $PathLogs -Name $folderName -ErrorAction SilentlyContinue
}
else {
Write-Host "[INFO] LogFolder already exists."
}
#Test for Logfile if not create it
if (!(Test-Path $PathToLogFile)) {
New-Item -itemType File -Path $Path -Name $logFileName -ErrorAction SilentlyContinue
}
else {
Write-Host "[INFO] LogFile already exists."
}
# START Webex Productivity Tools Removal
#Check installed versions of Webex Productivity Tools
$webexProdVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object { (($_.DisplayName -like "Cisco Webex Productivity*") -or ($_.Displayname -like "Webex Productivity*")) -and ($_.DisplayName -notlike "Webex Teams*") } |
Select-Object -Property DisplayName, DisplayVersion, UninstallString
$webexProdVerLog = $webexProdVer | Select-Object DisplayVersion -ExpandProperty DisplayVersion
$webexProdNameLog = $webexProdVer | Select-Object Displayname -ExpandProperty Displayname
$webexProdToRemoveLog = $webexProdNameLog + " " + $webexProdVerLog
$webexProdToKeepLog = $WebexProdToKeepName + " " + $webexProdToKeepVer + " and above."
#Get unsupported versions of Webex Productivity Tools except the version definded
if (($webExProd -eq $true) -and (($webexProdVer | Select-Object DisplayVersion -ExpandProperty DisplayVersion) -lt $webexProdToKeepVer)) {
Write-Host
Write-Host "==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====" -ForegroundColor Cyan
Write-Host " Unsupported Webex Product(s) to remove:"
Write-Host " --- $webexProdToRemoveLog >> remove" -ForegroundColor Red
Write-Host
Write-Host " Supported Version of Webex Product:"
Write-Host " --- $webexProdToKeepLog >> keep if installed" -ForegroundColor Green
Write-Host
#Build the log file at $pathLogs
Add-Content $PathToLogFile -Value "****************************************BEGIN****************************************"
if ($testModeEnabled) {
Add-Content $PathToLogFile -Value "***************************************TESTMODE**************************************"
}
Add-Content $PathToLogFile -Value "******************************Webex Productivity Tools*******************************"
Get-Date | Add-Content $PathToLogFile
Add-Content $PathToLogFile -Value "These unsupported Webex Productivity Tools Version(s) were removed from your system:"
$webexProdToRemoveLog | Add-Content $PathToLogFile
Add-Content $PathToLogFile -Value "Supported Webex Productivity Tools Version(s):"
$webexProdToKeepLog | Add-Content $PathToLogFile
Add-Content $PathToLogFile -Value "*****************************************END*****************************************"
Add-Content $PathToLogFile -Value ""
#END of log file
#Check if Test Mode is enabled for logging only; if not enabled run the removal at ELSE
if ($testModeEnabled) {
ForEach ($ver in $webexProdVer) {
if (($ver.UninstallString) -and (($webexProdVer | Select-Object DisplayVersion -ExpandProperty DisplayVersion) -lt $webexProdToKeepVer) -and ($ver.UninstallString -ne "C:\Program Files (x86)\Webex\Plugins\PluginsUninstaller.exe /ManualUninstall")) {
$uninst = $ver.UninstallString
Write-Host "TEST MODE" -ForegroundColor Green
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Green
Write-Host "Uninstall String: $uninst" -ForegroundColor Green
}
else {
$uninst = $ver.UninstallString
Write-Host "TEST MODE" -ForegroundColor Green
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Green
Write-Host "Uninstall String: $uninst" -ForegroundColor Green
}
}
}
#Get the removal string for each version found and split it.
else {
ForEach ($ver in $webexProdVer) {
if (($ver.UninstallString) -and (($webexProdVer | Select-Object DisplayVersion -ExpandProperty DisplayVersion) -lt $webexProdToKeepVer) -and ($ver.UninstallString -ne "C:\Program Files (x86)\Webex\Plugins\PluginsUninstaller.exe /ManualUninstall")) {
if ($ver.UninstallString -like "*/I*") {
$uninst = $ver.UninstallString
$uninstIDsplit = $uninst.Split("/I")
$uninstID = $uninstIDsplit[2]
Write-Host "PRODUCTION MODE" -ForegroundColor Yellow
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Yellow
Write-Host "Uninstall String: $uninst" -ForegroundColor Yellow
Start-Process cmd -ArgumentList "/c $removalProcess $uninstID /quiet /norestart" -wait -WindowStyle hidden
}
if ($ver.UninstallString -like "*/X*") {
$uninst = $ver.UninstallString
$uninstIDsplit = $uninst.Split("/X")
$uninstID = $uninstIDsplit[2]
Write-Host "PRODUCTION MODE" -ForegroundColor Yellow
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Yellow
Write-Host "Uninstall String: $uninst" -ForegroundColor Yellow
Start-Process cmd -ArgumentList "/c $removalProcess $uninstID /quiet /norestart" -wait -WindowStyle hidden
}
}
#Needed for very old installtion wich point uninstall.exe in the uninstall string.
else {
$uninst = $ver.UninstallString
Write-Host "PRODUCTION MODE" -ForegroundColor Yellow
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Yellow
Write-Host "Uninstall String: $uninst" -ForegroundColor Yellow
Start-Process cmd -ArgumentList "/c $uninst /S" -wait -WindowStyle hidden
}
}
}
}
#END Webex Productivity Tools Removal
#START Webex Meetings App Removal
#Check installed versions of Webex Meetings App
$webexMeetVer = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall, HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall |
Get-ItemProperty |
Where-Object { (($_.DisplayName -like "Cisco Webex Meeting*") -or ($_.Displayname -like "Webex Meeting*")) -and (($_.DisplayName -notlike "Webex Teams*")) } |
Select-Object -Property DisplayName, DisplayVersion, UninstallString
$webexMeetVerLog = $webexMeetVer | Select-Object DisplayVersion -ExpandProperty DisplayVersion
$webexMeetNameLog = $webexMeetVer | Select-Object Displayname -ExpandProperty Displayname
$webexMeetToRemoveLog = $webexMeetNameLog + " " + $webexMeetVerLog
$webexMeetToKeepLog = $WebexMeetToKeepName + " " + $webexMeetToKeepVer + " and above."
#Get unsupported versions of Webex Meetings App except the version definded
if (($webExMeet -eq $true) -and ((($webexMeetVer | Select-Object DisplayVersion -ExpandProperty DisplayVersion) -lt $webexMeetToKeepVer))) {
Write-Host
Write-Host "==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ==== ====" -ForegroundColor Cyan
Write-Host " Unsupported Webex Product(s) to remove:"
Write-Host " --- $webexMeetToRemoveLog >> remove" -ForegroundColor Red
Write-Host
Write-Host " Supported Version of Webex Product:"
Write-Host " --- $webexMeetToKeepLog >> keep if installed" -ForegroundColor Green
Write-Host
#Build the log file at $pathLogs
Add-Content $PathToLogFile -Value "****************************************BEGIN****************************************"
if ($testModeEnabled) {
Add-Content $PathToLogFile -Value "***************************************TESTMODE**************************************"
}
Add-Content $PathToLogFile -Value "***********************************Webex Meetings************************************"
Get-Date | Add-Content $PathToLogFile
Add-Content $PathToLogFile -Value "These unsupported Webex Meetings Version(s) were removed from your system:"
$webexMeetToRemoveLog | Add-Content $PathToLogFile
Add-Content $PathToLogFile -Value "Supported Webex Meetings Version(s):"
$webexMeetToKeepLog | Add-Content $PathToLogFile
Add-Content $PathToLogFile -Value "*****************************************END*****************************************"
Add-Content $PathToLogFile -Value ""
Add-Content $PathToLogFile -Value ""
#END of log file
#Check if Test Mode is enabled for logging only; if not enabled run the removal at ELSE
if ($testModeEnabled) {
ForEach ($ver in $webexMeetVer) {
If (($ver.UninstallString) -and (($webexMeetVer | Select-Object DisplayVersion -ExpandProperty DisplayVersion) -lt $webexMeetToKeepVer) -and ($ver.UninstallString -ne "C:\Program Files (x86)\Webex\Plugins\PluginsUninstaller.exe /ManualUninstall")) {
$uninst = $ver.UninstallString
Write-Host "TEST MODE" -ForegroundColor Green
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Green
Write-Host "Uninstall String: $uninst" -ForegroundColor Green
}
Else {
$uninst = $ver.UninstallString
Write-Host "TEST MODE" -ForegroundColor Green
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Green
Write-Host "Uninstall String: $uninst" -ForegroundColor Green
}
}
}
#Get the removal string for each version found and split it.
else {
ForEach ($ver in $webexMeetVer) {
if (($ver.UninstallString) -and (($webexMeetVer | Select-Object DisplayVersion -ExpandProperty DisplayVersion) -lt $webexMeetToKeepVer) -and ($ver.UninstallString -ne "C:\Program Files (x86)\Webex\Plugins\PluginsUninstaller.exe /ManualUninstall")) {
if ($ver.UninstallString -like "*/I*") {
$uninst = $ver.UninstallString
$uninstIDsplit = $uninst.Split("/I")
$uninstID = $uninstIDsplit[2]
Write-Host "PRODUCTION MODE" -ForegroundColor Yellow
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Yellow
Write-Host "Uninstall String: $uninst" -ForegroundColor Yellow
Start-Process cmd -ArgumentList "/c $removalProcess $uninstID /quiet /norestart" -wait -WindowStyle hidden
}
if ($ver.UninstallString -like "*/X*") {
$uninst = $ver.UninstallString
$uninstIDsplit = $uninst.Split("/X")
$uninstID = $uninstIDsplit[2]
Write-Host "PRODUCTION MODE" -ForegroundColor Yellow
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Yellow
Write-Host "Uninstall String: $uninst" -ForegroundColor Yellow
Start-Process cmd -ArgumentList "/c $removalProcess $uninstID /quiet /norestart" -wait -WindowStyle hidden
}
}
#Needed for very old installtion wich point uninstall.exe in the uninstall string.
else {
$uninst = $ver.UninstallString
Write-Host "PRODUCTION MODE" -ForegroundColor Yellow
Write-Host "Removing $($ver.DisplayName) $($ver.DisplayVersion )" -ForegroundColor Yellow
Write-Host "Uninstall String: $uninst" -ForegroundColor Yellow
Start-Process cmd -ArgumentList "/c $uninst /S" -wait -WindowStyle hidden
}
}
}
}
#END Webex Meetings App Removal
#END OF SCRIPT