114 lines
3.6 KiB
PowerShell
114 lines
3.6 KiB
PowerShell
<#
|
|
Author: Gabe Kerntke
|
|
Date: 05-30-2024
|
|
|
|
.Synopsis
|
|
Script checks to see if GoToMeeting is installed, if installed it will uninstall
|
|
|
|
.Modified
|
|
2024-02-21 (GabeK) - Original script created
|
|
|
|
#>
|
|
|
|
######################
|
|
### Variables ###
|
|
######################
|
|
$Name = "GoToMeeting"
|
|
|
|
######################
|
|
### Functions ###
|
|
######################
|
|
|
|
#Function checks for 32 or 64 bit processor and then pulls list of applications accordingly
|
|
Function Get-Software ($CPU = $ENV:PROCESSOR_ARCHITECTURE) {
|
|
If ($CPU -eq 'AMD64') {
|
|
$64bit = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\*
|
|
$32bit = Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*
|
|
$32bit + $64bit
|
|
}
|
|
Else { Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* }
|
|
}
|
|
|
|
#Function to uninstall via WMIobject (control panel)
|
|
Function UninstallGoToMeeting1 {
|
|
$Uninstall = Get-WmiObject Win32_Product -filter "name like '%$Name%'" | ForEach-Object { $_.Uninstall() }
|
|
$Value = $Uninstall | Select-Object -ExpandProperty ReturnValue
|
|
|
|
If ($Value -eq "0") {
|
|
Write-Host "$Name uninstalled successfully"
|
|
UninstallGoToMeeting5
|
|
}
|
|
else {
|
|
UninstallGoToMeeting2
|
|
}
|
|
}
|
|
|
|
Function UninstallGoToMeeting3 {
|
|
$UninstallString3 = $Applist | Select-Object -ExpandProperty UninstallString | Where-Object ($_.UninstallString -like "*MsiExec*")
|
|
$A = $UninstallString3 -replace "/I", "/X"
|
|
$A + " /qn" | cmd
|
|
If ($Applist.DisplayName -like "*$Name*") {
|
|
UninstallGoToMeeting4
|
|
}
|
|
Else {
|
|
Write-Host "$Name uninstalled successfully"
|
|
}
|
|
}
|
|
Function UninstallGoToMeeting2 {
|
|
$UninstallString2 = $Applist | Select-Object -ExpandProperty UninstallString | Where-Object ($_.UninstallString -like "*C:\*")
|
|
$UninstallString2 + " -silent" | cmd
|
|
If ($Applist.DisplayName -like "*$Name*") {
|
|
UninstallGoToMeeting3
|
|
}
|
|
Else {
|
|
Write-Host "$Name uninstalled successfully"
|
|
}
|
|
}
|
|
|
|
Function UninstallGoToMeeting4 {
|
|
$UninstallString4 = $Applist | Select-Object -ExpandProperty PSPath
|
|
$B = $UninstallString4 -replace "Microsoft.PowerShell.Core", ""
|
|
$C = $B.Substring(1)
|
|
Remove-Item -Path $C -Force -Verbose
|
|
|
|
If ($Applist.DisplayName -like "*$Name*") {
|
|
Write-Host "$Name uninstall failed"
|
|
UninstallGoToMeeting5
|
|
}
|
|
Else {
|
|
Write-Host "$Name uninstalled successfully"
|
|
}
|
|
}
|
|
|
|
Function UninstallGoToMeeting5 {
|
|
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
|
|
$RegistyPath = Get-ChildItem -Path HKU:\ | Select-Object -ExpandProperty Name
|
|
$Registy = $RegistyPath.Substring(10)
|
|
|
|
Foreach ($Reg in $Registy) {
|
|
Get-ChildItem HKU:$Reg | Where-Object { $_.Name -like "*gotomeeting*" } | Remove-Item -Force -Verbose -Recurse
|
|
Get-ChildItem HKU:$Reg | Where-Object { $_.Name -like "*G2M*" } | Remove-Item -Force -Verbose -Recurse
|
|
}
|
|
DeleteFolder
|
|
Write-Host "$Name removed successfully"
|
|
}
|
|
|
|
Function DeleteFolder {
|
|
$Path = "C:\Program Files (x86)\GoToMeeting"
|
|
If (Test-Path $Path) {
|
|
Remove-Item -Path $Path -Recurse -Force -Verbose
|
|
}
|
|
}
|
|
|
|
######################
|
|
### Script start ###
|
|
######################
|
|
|
|
$Applist = Get-Software | Where-Object { $_.DisplayName -like "*$Name*" }
|
|
If ($Applist.DisplayName -like "*$Name*") {
|
|
UninstallGoToMeeting1
|
|
}
|
|
Else {
|
|
Write-Host "$Name is not installed"
|
|
UninstallGoToMeeting5
|
|
} |