Public/Get-ChromeVersion.ps1
Function Get-ChromeVersion { <# .Synopsis Checks Google Chrome Web Browser version. .Description Checks Google Chrome Web Browser version on the local machine. Looks for a registry key to determine if Google Chrome is installed. You can check the version of Google Chrome by starting it and going to "Help->About Google Chrome" but that normally triggers the automatic update function, this is not always wanted. This function allows you to check what version is installed without triggering the automatic update feature. .Parameter ComputerName The computername (Default is localhost) .Example Get-ChromeVersion Shows the version of Google Chrome .Inputs None .Outputs JBOAPPLS.Google.Chrome.Version.Information .LINK about_functions_advanced .LINK about_CommonParameters #> [CmdletBinding()] [OutputType('JBOAPPLS.Google.Chrome.Version.Information')] Param ( [Parameter( ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True, HelpMessage = 'Provide computernames' )] [Alias('cn', 'Identity', 'Hostname', 'Server')] [string[]]$ComputerName = $env:COMPUTERNAME ) Begin { If (-not $PSBoundParameters.ContainsKey('Verbose')) { $VerbosePreference = $PSCmdlet.SessionState.PSVariable.GetValue('VerbosePreference') } If (-not $PSBoundParameters.ContainsKey('ErrorAction')) { $ErrorActionPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ErrorActionPreference') } $RegKey = "HKLM:\SOFTWARE\Clients\StartMenuInternet\Google Chrome\shell\open\command" } Process { Write-Verbose ('{0}:: Retrieving data' -f $MyInvocation.MyCommand) Foreach ($Computer in $ComputerName) { Try { #$Session = New-PSSession -ComputerName $Computer -Name Get-ChromeVersion #Enter-PSSession -Session $Session Function Get-CurrentChromeVersion { [CmdletBinding()] Param ( [Parameter(Mandatory = $False)] [string] $Uri = "https://omahaproxy.appspot.com/all.json", [Parameter(Mandatory = $False)] [ValidateSet('win', 'win64', 'mac', 'linux', 'ios', 'cros', 'android', 'webview')] [string] $Platform = "win", [Parameter(Mandatory = $False)] [ValidateSet('stable', 'beta', 'dev', 'canary', 'canary_asan')] [string] $Channel = "stable" ) # Read the JSON and convert to a PowerShell object. Return the current release version of Chrome $chromeVersions = (Invoke-WebRequest -uri $Uri).Content | ConvertFrom-Json $output = (($chromeVersions | Where-Object { $_.os -eq $Platform }).versions | ` Where-Object { $_.channel -eq $Channel }).current_version Write-Output $output } $CurrentChromeVersion = Get-CurrentChromeVersion If (($null -ne $RegKey)) { Write-Verbose ('{0}:: Processing RegKey {1}' -f $MyInvocation.MyCommand, $RegKey) $ChromeInstallPath = Get-ItemProperty -Path "HKLM:\SOFTWARE\Clients\StartMenuInternet\Google Chrome\shell\open\command" $ChromeInstallPath = $ChromeInstallPath.'(default)' $path = $ChromeInstallPath -replace "`"", "" $path = $path -replace "chrome.exe", "" $path = $path.TrimStart() Write-Verbose ('{0}:: Testing Google Chrome installation in {1}' -f $MyInvocation.MyCommand, $Path) If ((Test-Path $path\chrome.exe)) { #Set-Location $path $Version = (Get-Command $path\chrome.exe | ForEach-Object { $_.FileVersionInfo }).ProductVersion $properties = @{ PSTypeName = 'JBOAPPLS.Google.Chrome.Version.Information' ComputerName = $ComputerName "Installed Version" = $Version "Available Version" = $CurrentChromeVersion Status = If ($Version -eq $CurrentChromeVersion) { "Up-to-Date" } Else { "Out-of-Date" } } $ChromeVersion = New-Object psobject -Property $properties } } Else { $properties = @{ PSTypeName = 'JBOAPPLS.Google.Chrome.Version.Information' ComputerName = $ComputerName "Installed Version" = $null "Available Version" = $CurrentChromeVersion Status = 'Not Installed' } $ChromeVersion = New-Object psobject -Property $properties } } Catch { $properties = @{ PSTypeName = 'JBOAPPLS.Google.Chrome.Version.Information' ComputerName = $ComputerName "Installed Version" = $null "Available Version" = $CurrentChromeVersion Status = "Not Installed" } $ChromeVersion = New-Object psobject -Property $properties } Finally { Exit-PSSession } } } End { Write-Output $ChromeVersion } } |