Classes/GoogleChromeManager.ps1

class GoogleChromeManager {
    [LibraryContext]$Context
    
    GoogleChromeManager([LibraryContext]$context) {
        $this.Context = $context
    }

    [string]FindChrome() {
        $path = $null
        try {
            $path = Join-Path (Get-ChildItem "C:\Program Files\Google\Chrome\Application\" -Directory -ErrorAction SilentlyContinue | Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' } | Sort-Object Name | Select-Object -Last 1).FullName "Installer\setup.exe"
            $this.Context.LogManager.Log("Found chrome at $path")
        } catch {
            $this.Context.LogManager.Log("Chrome not installed", "WARN")
        }

        return $path
    }

    [void]Uninstall() {
        $chrome = $this.FindChrome()
        if ($chrome) {
            $args = " --uninstall --multi-install --chrome --msi --system-level --force-uninstall"
            $this.Context.ExeExecuteManager.Run($null, $chrome, $args, $null)
        }
    }
}